# Written by Flavio

namespace=HF
namespace=IZCOR

# Explain coronation preparation, ask whom to ask to be crowned by.
character_event = {
	id = HF.20200
	title = EVTTITLE20200
	desc = EVTDESCHF20200

	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = { #Ask to be crowned by the Pope
		name = EVTOPTAHF20200
		trigger = { 
			NOT = { trait = excommunicated }
			rightful_religious_head_scope = { 
				is_alive = yes 
				NOT = { block_general_event_trigger = yes }
				OR = { 
					has_landed_title = k_papal_state
					has_landed_title = d_fraticelli
				} 
			} 
		}
		religion_head = { show_portrait = THIS }
		custom_tooltip = { text = EVTTOOLTIPHF20201 }
		hidden_tooltip = { religion_head = { letter_event = { id = IZCOR.1000 days = 30 random = 5 } } }
		ai_chance = { 
			factor = 70
			modifier = {
				factor = 0.7
				tier = EMPEROR
			}
			modifier = {
				factor = 0.1
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -80 
						} 
					}
				}
			}
			modifier = {
				factor = 0.25
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -60 
						} 
					}
				}
			}
			modifier = {
				factor = 0.5
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -40 
						} 
					}
				}
			}
			modifier = {
				factor = 0.7
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -20 
						} 
					}
				}
			}
			modifier = {
				factor = 0.8
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 0 
						} 
					}
				}
			}
			modifier = {
				factor = 1.25
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 20 
						} 
					}
				}
			}
			modifier = {
				factor = 1.25
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 40 
						} 
					}
				}
			}
			modifier = {
				factor = 1.5
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 60 
						} 
					}
				}
			}
			modifier = {
				factor = 1.75
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 80 
						} 
					}
				}
			}
			modifier = {
				factor = 2
				religion_head = { 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = 100 
						} 
					}
				}
			}
		}
	}
	option = { #Invested by powerful Bishop
		name = EVTOPTBHF20200
		trigger = { 
			NOT = { trait = excommunicated }
			OR = { 
				lower_tier_than = EMPEROR
				primary_title = { has_law = investiture_law_1 }
			} 
			any_realm_character = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				religion = ROOT
				NOT = { block_general_event_trigger = yes }
				OR = { 
					higher_tier_than = BARON  
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
				NOT = { has_landed_title = k_papal_state }
				NOT = { has_landed_title = d_fraticelli }
			}
		}
		custom_tooltip = { text = EVTTOOLTIPBHF20200 }
		if = { #If Pope is available but he's snubbed by an Emperor, he'll get mad.
			limit = { 
				tier = EMPEROR
				religion_head = { 
					is_alive = yes 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					} 
				}
			}
			custom_tooltip = { text = scorned_the_pope }
			hidden_tooltip = { 
				religion_head = { 		
					show_scope_change = no	
					opinion = {
						modifier = opinion_offended
						years = 30
						who = ROOT
					} 
				} 
			}
		}
		
		random_realm_character = { 
			limit = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				religion = ROOT
				NOT = { block_general_event_trigger = yes }
				OR = { 
					higher_tier_than = BARON  
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
				NOT = { has_landed_title = k_papal_state }
				NOT = { has_landed_title = d_fraticelli }
			}
			preferred_limit = { #First search for a possible antipopes.
				any_claim = { title = k_papal_state } 
			}
			preferred_limit = { 
				any_claim = { title = d_fraticelli } 
			}
			preferred_limit = { 
				has_minor_title = title_cardinal
			}
			preferred_limit = { 
				has_minor_title = title_fraticelli_cardinal
			}
			hidden_tooltip = { letter_event = { id = HF.20201 days = 30 random = 5 } } 
			break = yes
		}
		ai_chance = { 
			factor = 30
			modifier = { factor = 1 

			} 
		}
	}
	option = { #Invested by random priest
		name = EVTOPTCHF20200
		trigger = { 
			OR = { 
				lower_tier_than = EMPEROR
				primary_title = { has_law = investiture_law_1 }
			} 
			any_realm_character = { 
				is_theocracy = yes 
				any_liege = { character = ROOT }
				lower_tier_than = COUNT
				religion = ROOT
				NOR = { 
					has_landed_title = k_papal_state
					has_landed_title = d_fraticelli
					higher_real_tier_than = BARON 
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } #Antipope
				}
			}
		}
		custom_tooltip = { text = EVTTOOLTIPCHF20200 }
		if = { #Emperors not crowned by Pope or Antipope receive an additional penalty
			limit = { tier = EMPEROR }
			prestige = -300
			piety = -75
		}
		if = { #If Pope is available but he's snubbed by an Emperor, he'll get mad.
			limit = { 
				tier = EMPEROR
				religion_head = { 
					is_alive = yes 
					OR = { 
						has_landed_title = k_papal_state
						has_landed_title = d_fraticelli
					} 
				}
			}
			custom_tooltip = { text = scorned_the_pope }
			hidden_tooltip = { 
				religion_head = { 		
					show_scope_change = no	
					opinion = {
						modifier = opinion_offended
						years = 30
						who = ROOT
					} 
				} 
			}
		}
		if = { #If powerful theocrats are available but player picks random priest, the other theocrats will be mad.
			limit = { 
				OR = { 
					lower_tier_than = EMPEROR
					primary_title = { has_law = investiture_law_1 }
				} 
				NOT = { trait = excommunicated }
				any_realm_character = { 
					is_theocracy = yes 
					religion = ROOT
					any_liege = { character = ROOT }
					NOT = { block_general_event_trigger = yes }
					OR = { 
						higher_real_tier_than = BARON 
						has_minor_title = title_cardinal
						has_minor_title = title_fraticelli_cardinal
						any_claim = { title = k_papal_state } #Antipope
						any_claim = { title = d_fraticelli } 
					}
					NOT = { has_landed_title = k_papal_state }
					NOT = { has_landed_title = d_fraticelli }
				}
			}
			custom_tooltip = { text = scorned_powerful_theocrats }
			hidden_tooltip = { 
				any_realm_character = { 
					limit = {
						is_theocracy = yes 
						religion = ROOT
						any_liege = { character = ROOT }
						NOT = { block_general_event_trigger = yes }
						OR = { 
							higher_real_tier_than = BARON 
							has_minor_title = title_cardinal
							has_minor_title = title_fraticelli_cardinal
							any_claim = { title = k_papal_state } #Antipope
							any_claim = { title = d_fraticelli } 
						}
						NOT = { has_landed_title = k_papal_state }
						NOT = { has_landed_title = d_fraticelli }
					}			
					opinion = {
						modifier = opinion_offended
						years = 10
						who = ROOT
					} 
				}
			}
		}
		random_realm_character = { 
			limit = {
				is_theocracy = yes 
				lower_tier_than = COUNT
				religion = ROOT
				any_liege = { character = ROOT }
				NOT = { block_general_event_trigger = yes }
				NOR = { 
					has_landed_title = k_papal_state
					has_landed_title = d_fraticelli
					higher_real_tier_than = BARON 
					has_minor_title = title_cardinal
					has_minor_title = title_fraticelli_cardinal
					any_claim = { title = k_papal_state } #Antipope
					any_claim = { title = d_fraticelli } 
				}
			}
			preferred_limit = { 
				opinion = { 
					who = ROOT
					value = 50 
				}
			}
			preferred_limit = { 
				opinion = { 
					who = ROOT
					value = 20 
				}
			}
			hidden_tooltip = { letter_event = { id = HF.20201 days = 30 random = 5 } } 
			break = yes
		}
		ai_chance = { 
			factor = 10
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 1.5
				trait = shy
			}
			modifier = {
				factor = 1.25
				trait = content
			}
			modifier = {
				factor = 0.7
				trait = proud
			}
			modifier = {
				factor = 0.7
				trait = ambitious
			}
			modifier = {
				factor = 0.7
				tier = EMPEROR
			}
			modifier = {
				factor = 0.5
				has_landed_title = e_hre
			}
		}
	}
	option = { #Changed your mind, not yet.
		name = EVTOPTDHF20200
		custom_tooltip = { text = coronation_canceled }
		##clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		hidden_tooltip = { remove_character_modifier = coronation_request_cooldown }
		ai_chance = { factor = 0 }	
	}
}

#Custom player Pope letter event
letter_event = {
	id = IZCOR.1000
	desc = IZCOR.1000.desc
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = IZCOR.1000.a
		trigger = {
					vassal_of = FROM
		}
		FROM = { letter_event = { id = HF.20211 } } #I want to be independent.
	}

	option = {
		name = IZCOR.1000.b
		FROM = { letter_event = { id = HF.20212 } } #I want gold.
	}
	
	option = {
		name = IZCOR.1000.c
		trigger = {
			FROM = { primary_title = { has_law = investiture_law_1 } }
		}
		FROM = { letter_event = { id = HF.20213 } } #I want you to enact Papal Investiture.
	}	

	option = {
		name = IZCOR.1000.d
		trigger = {
			FROM = { war = no } #Wartime coronation.
			any_independent_ruler = { 
				is_within_diplo_range = FROM
				excommunicated_for = ROOT
				in_revolt = no
				NOT = { is_liege_of = FROM }
				NOT = { is_allied_with = ROOT }
				NOT = { 
					any_current_enemy = {
						NOT = { religion_group = ROOT }
					}
				}
			}

		}
		FROM = { letter_event = { id = HF.20214 } } #I want you to depose excommunicated ruler.
	}
	
	option = {
		name = IZCOR.1000.e
		trigger = {
			FROM = { war = no } #Wartime coronation.
				any_independent_ruler = {
					religion = FROM
					is_within_diplo_range = FROM
					NOT = { is_allied_with = ROOT }
					OR = {
						religion = catholic
						religion = fraticelli
					}
					rightful_religious_head_scope = {
						is_liege_or_above = PREV
						OR = {
							has_claim = k_papal_state
							has_claim = d_fraticelli
						}
					}
				}
		}
		FROM = { letter_event = { id = HF.20215 } } #I want you to depose an antipope.	
	}
	
	option = {
		name = IZCOR.1000.f
		trigger = {
				FROM = {
					NOT = { lower_tier_than = EMPEROR }
					OR = {
						any_demesne_title = {
						can_be_given_away = yes
						OR = {
							title = d_latium
							title = d_spoleto
							title = d_ancona
							title = d_ferrara
							title = d_benevento
							title = c_roma
							}
						}
						any_vassal = {
							any_demesne_title = {
							OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									title = c_roma
								}
							}
						}
					}
				}
		}
		if = { 
			limit = {
				NOR = { 
					trait = lunatic 
					trait = possessed
				}
			} 
			FROM = { letter_event = { id = HF.20216 } } #I want a piece of Italy.
		}
		if = {
			limit = {
				OR = {
					trait = lunatic 
					trait = possessed
				}
			} 
			FROM = { letter_event = { id = HF.20225 } } #Calls for Donation of Constantine.
		}
	}
	
	option = {
		name = IZCOR.1000.g
		trigger = {
			FROM = { war = no } #Wartime coronation.
			OR = {
				trait = bad_priest_christian
				trait = hedonist
			}
			NOR = {
				trait = celibate
				trait = temperate
			}
			NOT = { has_landed_title = d_fraticelli }
		}
		FROM = { letter_event = { id = HF.20235 } } #Wishes to have orgy.
	}	
	
	option = {
		name = IZCOR.1000.h
		trigger = { #Check if holy orders exist.
			OR = { 
				is_title_active = d_knights_templar 
				is_title_active = d_teutonic_order 
				is_title_active = d_knights_hospitaler 
				is_title_active = d_knights_santiago 
				is_title_active = d_knights_calatrava 
			}
			FROM = { 
				higher_real_tier_than = KING 
				any_demesne_title = { #Check if you have enough land to give.
					can_be_given_away = yes
					tier = duke
				}
			}
		}
		FROM = { letter_event = { id = HF.20217 } } #Give lands to the Holy Orders.	
	}
	
	option = {
		name = IZCOR.1000.i
		trigger = {
			FROM = {
					any_artifact = { 
						has_artifact_flag = christian 
						OR = { 
							has_artifact_flag = rare
							has_artifact_flag = very_rare
						}
					}
			}		
		}
		FROM = { letter_event = { id = HF.20241 } } #Give me an artifact.		
	}	
	
	option = {
		name = IZCOR.1000.j
		trigger = { #Check if a potential target exists (either an infidel, a heretic, or a hated Christian ruler).
			FROM = { higher_tier_than = KING war = no }
			any_independent_ruler = {
				is_within_diplo_range = FROM
				NOT = { is_allied_with = ROOT }
				OR = { 
					excommunicated_for = ROOT
					NOT = { religion = ROOT }
					NOT = { 
						opinion = { 
							who = ROOT 
							value = -50
						} 
					}
				}
				OR = {
					any_demesne_title = {
						OR = {
							title = d_latium
							title = d_spoleto
							title = d_ancona
							title = d_ferrara
							title = d_benevento
							d_latium = {
								any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
							}
							d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
							}
							d_ancona = {
								any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
							}
							d_ferrara = {
								any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
							}
							d_benevento = {
								any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
							}
						}
					}
					any_vassal = {	
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}		
					}
				}
			}
		}
		FROM = { letter_event = { id = HF.20221 } } #Holy war Italy for me.
	}	
	}
		
#Scary giant letter event determining what is the priest going to ask to the King/Emperor in exchange for the Coronation.
letter_event = {
	id = HF.20201
	desc = EVTDESCHFA20201
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes
	trigger = {
		FROM = { 
			religion = ROOT
			OR = {
				religion = catholic
				religion = fraticelli
			}
		}
	}
	
	option = { #For random priest
		name = EVTOPTAHF20201
		trigger = { 
			NOR = { 
				has_landed_title = k_papal_state
				has_landed_title = d_fraticelli
				higher_real_tier_than = BARON 
				has_minor_title = title_cardinal
				has_minor_title = title_fraticelli_cardinal
				any_claim = { title = k_papal_state } #Antipope
				any_claim = { title = d_fraticelli } 
			}
		}
		random_list = { 
			50 = {
				modifier = {
					factor = 0
					NOT = { 
						opinion = { 
							who = FROM
							value = -100 
						} 
					}
				}
				modifier = {
					factor = 0.5
					NOT = { 
						opinion = { 
							who = FROM
							value = -80 
						} 
					}
				}
				modifier = {
					factor = 0.6
					NOT = { 
						opinion = { 
							who = FROM
							value = -60 
						} 
					}
				}
				modifier = {
					factor = 0.7
					NOT = { 
						opinion = { 
							who = FROM
							value = -40 
						} 
					}
				}
				modifier = {
					factor = 0.8
					NOT = { 
						opinion = { 
							who = FROM
							value = -20 
						} 
					}
				}
				modifier = {
					factor = 1.25
					opinion = { 
						who = FROM
						value = 20 
					} 
				}
				modifier = {
					factor = 1.5
					opinion = { 
						who = FROM
						value = 40 
					} 
				}
				modifier = {
					factor = 1.5
					opinion = { 
						who = FROM
						value = 60 
					} 
				}
				modifier = {
					factor = 1.75
					opinion = { 
						who = FROM
						value = 80 
					} 
				}
				modifier = {
					factor = 2
					opinion = { 
						who = FROM
						value = 100 
					} 
				}
				FROM = { letter_event = { id = HF.20202 } } #Priest asks for nothing, proceed with coronation.
			} 
		
			50 = {  
				modifier = {
					factor = 1.5
					trait = greedy
				}
				modifier = {
					factor = 1.25
					trait = slothful
				}
				modifier = {
					factor = 1.25
					trait = envious
				}
				modifier = {
					factor = 1.5
					trait = bad_priest_christian
				}
				FROM = { letter_event = { id = HF.20203 } } #Priest asks for small donation.
			}
		}
	}
	option = { #For powerful theocrat
		name = EVTOPTBHF20201
		trigger = { 
			NOR = { 
				has_landed_title = k_papal_state
				has_landed_title = d_fraticelli
			}
			OR = { 
				has_landed_title = k_papal_state
				has_landed_title = d_fraticelli
				higher_real_tier_than = BARON 
				has_minor_title = title_cardinal
				has_minor_title = title_fraticelli_cardinal
				any_claim = { title = k_papal_state } #Antipope
				any_claim = { title = d_fraticelli } 
			}
		}
		random_list = { 
			40 = { 
				modifier = {
					factor = 1.5
					trait = greedy
				}
				modifier = {
					factor = 1.25
					trait = slothful
				}
				modifier = {
					factor = 1.25
					trait = envious
				}
				modifier = {
					factor = 0
					NOT = { 
						opinion = { 
							who = FROM
							value = -100 
						} 
					}
				}
				modifier = {
					factor = 0.5
					NOT = { 
						opinion = { 
							who = FROM
							value = -80 
						} 
					}
				}
				modifier = {
					factor = 0.6
					NOT = { 
						opinion = { 
							who = FROM
							value = -60 
						} 
					}
				}
				modifier = {
					factor = 0.7
					NOT = { 
						opinion = { 
							who = FROM
							value = -40 
						} 
					}
				}
				modifier = {
					factor = 0.8
					NOT = { 
						opinion = { 
							who = FROM
							value = -20 
						} 
					}
				}
				FROM = { letter_event = { id = HF.20204 } } #Donate money to me.
			} 
			40 = { 
				modifier = {
					factor = 0
					rightful_religious_head_scope = { character = ROOT }
				}
				modifier = {
					factor = 0
					OR = { 
						trait = cynical 
						trait = bad_priest_christian
					}
				}
				modifier = {
					factor = 1.5
					trait = charitable
				}
				modifier = {
					factor = 1.5
					trait = zealous
				}
				modifier = {
					factor = 0.5
					trait = bad_priest_christian
				}
				modifier = { 	#Antipope more likely to ask for little
					factor = 1.5
					has_opinion_modifier = { 
						who = FROM 
						modifier = opinion_controlled_antipope 
					}
				}
				modifier = { 	#Supported Cardinal more likely to ask for little
					factor = 1.5
					has_opinion_modifier = { 
						who = FROM 
						modifier = opinion_supported_cardinal 
					}
				}
				modifier = {
					factor = 0
					NOT = { 
						opinion = { 
							who = FROM
							value = -100 
						} 
					}
				}
				modifier = {
					factor = 0.5
					NOT = { 
						opinion = { 
							who = FROM
							value = -80 
						} 
					}
				}
				modifier = {
					factor = 0.6
					NOT = { 
						opinion = { 
							who = FROM
							value = -60 
						} 
					}
				}
				modifier = {
					factor = 0.7
					NOT = { 
						opinion = { 
							who = FROM
							value = -40 
						} 
					}
				}
				modifier = {
					factor = 0.8
					NOT = { 
						opinion = { 
							who = FROM
							value = -20 
						} 
					}
				}
				FROM = { letter_event = { id = HF.20205 } } #Donate money to the Pope.
			} 
			20 = { 
				trigger = {
					FROM = { 
						any_child = { 
							age = 16
							is_married = no
							is_ruler = no
							prisoner = no
							NOT = { trait = incapable }
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 3
							age = 16
							is_married = no
							is_ruler = no
							prisoner = no
							NOT = { trait = incapable }
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 4
							age = 16
							is_married = no
							is_ruler = no
							prisoner = no
							NOT = { trait = incapable }
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 5
							age = 16
							is_married = no
							is_ruler = no
							prisoner = no
							NOT = { trait = incapable }
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 6
							age = 16
							is_married = no
							is_ruler = no
							prisoner = no
							NOT = { trait = incapable }
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 0.25
					trait = bad_priest_christian
				}
				modifier = {
					factor = 0.25
					trait = cynical
				}
				FROM = { letter_event = { id = HF.20206 } } #Send child to monastery/nunnery.
			} 
			10 = { 
				trigger = { #Check if holy orders exist.
					OR = { 
						is_title_active = d_knights_templar 
						is_title_active = d_teutonic_order 
						is_title_active = d_knights_hospitaler 
						is_title_active = d_knights_santiago 
						is_title_active = d_knights_calatrava 
					}
					FROM = { 
						any_child = { 
							age = 16
							is_ruler = no
							is_female = no
							prisoner = no
							NOT = { trait = incapable }
							vassal_of = FROM
							ROOT_FROM = {
								NOT = { 
									current_heir = { character = PREVPREV  }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 3
							age = 16
							is_ruler = no
							is_female = no
							prisoner = no
							NOT = { trait = incapable }
							vassal_of = FROM
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV  }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 4
							age = 16
							is_ruler = no
							is_female = no
							prisoner = no
							NOT = { trait = incapable }
							vassal_of = FROM
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV  }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 5
							age = 16
							is_ruler = no
							is_female = no
							prisoner = no
							NOT = { trait = incapable }
							vassal_of = FROM
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV  }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = { 
						any_child = { 
							count = 6
							age = 16
							is_ruler = no
							is_female = no
							prisoner = no
							NOT = { trait = incapable }
							vassal_of = FROM
							FROM = {
								NOT = { 
									current_heir = { character = PREVPREV  }
								}
							}
							NOR = { 
								trait = monk 
								trait = nun
							} 
						}
					}
				}
				modifier = {
					factor = 0.25
					trait = bad_priest_christian
				}
				modifier = {
					factor = 0.25
					trait = cynical
				}
				FROM = { letter_event = { id = HF.20207 } } #Send son to holy order.
			} 
			10 = { 
				trigger = {
					FROM = { war = no }
				}
				modifier = {
					factor = 0
					NOT = { trait = bad_priest_christian }
					NOT = { trait = hedonist }
				}
				modifier = {
					factor = 0
					OR = {
						 trait = celibate
						 trait = temperate
					}
				}
				modifier = {
					factor = 1.5
					trait = gluttonous
				}
				modifier = {
					factor = 1.5
					trait = drunkard
				}
				modifier = {
					factor = 1.5
					trait = greedy
				}
				modifier = {
					factor = 1.25
					trait = cynical
				}
				modifier = {
					factor = 0.5
					trait = zealous
				}
				FROM = { letter_event = { id = HF.20208 } } #Wishes to have orgy for himself.
			} 
			10 = { 
				modifier = {
					factor = 0
					NOT = {
						FROM = {
							any_demesne_title = {
								can_be_given_away = yes
								tier = count
								is_feudal = yes
								location = {
									is_capital = no
								}
							}
						}
					}
				}
				modifier = {
					factor = 1.5
					FROM = {
						any_demesne_title = {
							can_be_given_away = yes
							tier = count
							is_feudal = yes
							count = 2
							location = {
								is_capital = no
							}
						}
					}
				}
				modifier = {
					factor = 2
					FROM = {
						any_demesne_title = {
							can_be_given_away = yes
							tier = count
							is_feudal = yes
							count = 5
							location = {
								is_capital = no
							}
						}
					}
				}
				FROM = { letter_event = { id = HF.20209 } } #Wishes for another County.
			} 
			10 = { 
				modifier = {
					factor = 0
					FROM = {
						is_monastic_member_trigger = yes
					}
				}
				modifier = {
					factor = 0
					is_monastic_member_trigger = no
				}
				modifier = {
					factor = 1.5
					trait = zealous
				}
				modifier = {
					factor = 1.5
					trait = scholar
				}
				modifier = {
					factor = 1.5
					trait = socializer
				}
				modifier = {
					factor = 1.25
					trait = gregarious
				}
				FROM = { letter_event = { id = HF.20210 } } #Join my Monastic Order.
			}
			10 = { 
				modifier = {
					factor = 0
					NOT = {
						FROM = {
							any_artifact = { 
								has_artifact_flag = christian 
								NOR = { 
									has_artifact_flag = rare
									has_artifact_flag = very_rare
								}
							}
						}
					}
				}
				modifier = {
					factor = 1.5
					trait = zealous
				}
				modifier = {
					factor = 1.5
					trait = scholar
				}
				modifier = {
					factor = 1.5
					trait = theologian
				}
				modifier = {
					factor = 1.5
					trait = mystic
				}
				FROM = { letter_event = { id = HF.20240 } } #Give me a relic.
			} 
		}
	}
}

#King: Random Priest doesn't ask for anything, proceed with the coronation immediately.
letter_event = {
	id = HF.20202
	desc = EVTDESCHFA20202
	border = GFX_event_letter_frame_religion
	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20202
		set_character_flag = flag_crowned_by_priest
		FROM = { 
			save_event_target_as = coronation_priest 
			show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20202
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Random Priest asks for small donation.
letter_event = {
	id = HF.20203
	desc = EVTDESCHFA20203
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20203
		set_character_flag = flag_crowned_by_priest
		FROM = { 
			save_event_target_as = coronation_priest 
			show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		wealth = -50
		hidden_tooltip = { FROM = { wealth = 50 } }
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20203
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Bishop asks for donation to himself.
letter_event = {
	id = HF.20204
	desc = EVTDESCHFA20204
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20204
		set_character_flag = flag_crowned_by_bishop
		FROM = { 
			save_event_target_as = coronation_priest 
			show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		wealth = -150
		hidden_tooltip = { FROM = { wealth = 150 } }
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20204
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Bishop asks for donation to the Pope.
letter_event = {
	id = HF.20205
	desc = EVTDESCHFA20205
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20205
		set_character_flag = flag_crowned_by_bishop
		FROM = { 
				show_scope_change = no	
			save_event_target_as = coronation_priest
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		wealth = -100
		hidden_tooltip = { rightful_religious_head_scope = { wealth = 100 } }
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20205
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Bishop asks for child to become monk/nun.
letter_event = {
	id = HF.20206
	desc = EVTDESCHFA20206
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	immediate = { 
		random_child = { 
			limit = { 
				age = 16
				is_married = no
				is_ruler = no
				prisoner = no
				NOT = { trait = incapable }
				liege = { character = ROOT }
				ROOT = {
					NOT = { 
						current_heir = { character = PREVPREV }
					}
				}
				NOR = { 
					trait = monk 
					trait = nun
				}
			}
			save_event_target_as = son_monk_candidate
		}
	} 
	
	option = {
		name = EVTOPTAHF20206
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		religion_head = { 
			event_target:son_monk_candidate = { 
				if = {
					limit = { is_female = yes }
					add_trait = nun
				}
				if = {
					limit = { is_female = no }
					add_trait = monk
				}
				move_character = PREV
			}
		}
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20206
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}
#King: Bishop asks for son to join holy order.
letter_event = {
	id = HF.20207
	desc = EVTDESCHFA20207
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes

	immediate = { 
		random_child = { 
			limit = { 
				age = 16
				is_married = no
				is_ruler = no
				is_female = no
				prisoner = no
				NOT = { trait = incapable }
				liege = { character = ROOT }
				ROOT = {
					NOT = { 
						current_heir = { character = PREVPREV }
					}
				}
				NOR = { 
					trait = monk 
					trait = nun
				}
			}
			save_event_target_as = son_holyorder_candidate
		}
		random_playable_ruler = { 
			limit = { 
				religion = ROOT
				OR = { 
					has_landed_title = d_knights_templar
					has_landed_title = d_teutonic_order
					has_landed_title = d_knights_hospitaler
					has_landed_title = d_knights_santiago
					has_landed_title = d_knights_calatrava 
				} 
			}
			save_event_target_as = son_holyorder_host
		}
	} 
	
	
	option = {
		name = EVTOPTAHF20207
		set_character_flag = flag_crowned_by_bishop
		show_portrait = event_target:son_holyorder_host
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		event_target:son_holyorder_host = { 
			show_scope_change = no
			event_target:son_holyorder_candidate = { 
				show_scope_change = no
				add_trait = celibate
				move_character = PREV
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20207
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Bishop wants an orgy. 
letter_event = {
	id = HF.20208
	desc = EVTDESCHFA20208
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	#Fund AND join the Orgy
	option = {
		name = EVTOPTZHF20208
		custom_tooltip = { text = join_bishop_orgy }
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
		}
		transfer_scaled_wealth = { to = FROM value = 0.5 min = 50 max = 200 } 
		tiered_piety_negative_effect = yes
		hidden_tooltip = { 
			FROM = { 
				tiered_piety_negative_effect = yes
			} 
		}
		hidden_tooltip = { character_event = { id = HF.20236 } } #Small event chain.
		#hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 10 }
	}
	option = {
		name = EVTOPTAHF20208
		trigger = { NOT = { trait = hedonist } }
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
		}
		transfer_scaled_wealth = { to = FROM value = 0.5 min = 50 max = 200 } 
		piety = -50
		hidden_tooltip = { 
			FROM = { 
				tiered_piety_negative_effect = yes
			} 
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20208
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}


#King: Bishop wants a county
letter_event = {
	id = HF.20209
	desc = EVTDESCHFA20209
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes
	
	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	option = {
		name = EVTOPTAHF20209
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		random_demesne_title = { 
			limit = {
				can_be_given_away = yes
				tier = count
				is_feudal = yes
				location = {
					is_capital = no
				}
			}
			grant_title = FROM
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20209
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}
#King: Bishop wants you to join his monastic order
letter_event = {
	id = HF.20210
	desc = EVTDESCHFA20210
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20210	
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}	
        FROM = { ROOT = { join_prev_monastic_order_society = yes } }
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20210
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Pope wants to be independent
letter_event = {
	id = HF.20211
	desc = EVTDESCHFA20211
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20211
		set_character_flag = flag_crowned_by_pope
		custom_tooltip = { text = TT_EVTOPTAHF20211 }
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { 
       		FROM = { 
       			character_event = { id = HF.20234 } 
       		} 
       	}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20211
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
			 # The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_independence
				years = 10
				who = ROOT
			}
		} 
		ai_chance = { factor = 0 }
	}
}

#King: Pope wants gold.
letter_event = {
	id = HF.20212
	desc = EVTDESCHFA20212
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20212
		hidden_tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = { 
			limit = { real_tier = KING }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 } 
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = { 
			limit = { real_tier = EMPEROR }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 } 
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20212
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Pope wants Papal Investiture
letter_event = {
	id = HF.20213
	desc = EVTDESCHFA20213
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20213
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		primary_title = {
			revoke_law = investiture_law_1
			add_law_w_cooldown = investiture_law_0
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20213
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_papal_investiture
				years = 10
				who = ROOT
			}
		} 
		ai_chance = { factor = 0 }
	}
}
#King: Pope wants an Excommunicated Ruler deposed
letter_event = {
	id = HF.20214
	desc = {
		text = EVTDESCHFA20214
		trigger = { 
			event_target:excommunication_war_target = { is_alive = yes }
		}
	}
	desc = { #If target has been invalidated in the meantime for whatever reason, default to money donation.
		text = EVTDESCHFA20212
		trigger = { 
			NOT = { event_target:excommunication_war_target = { is_alive = yes } }
		}
	}
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	#Select potential target so that it appears in the tooltip
	immediate = {
		random_independent_ruler = { 
			limit = {
				is_within_diplo_range = ROOT
				excommunicated_for = ROOT
				in_revolt = no
				NOT = { is_liege_of = FROM }
				NOT = { is_allied_with = FROM }
				NOT = { 
					any_current_enemy = {
						NOT = { religion_group = ROOT }
					}
				}
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 50 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 100 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 150 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 50 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 100 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 150 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { relative_power = { who = ROOT power = 4 } }
			}
		save_event_target_as = excommunication_war_target 
		}
	}
	option = {
		name = EVTOPTAHF20214
		trigger = { event_target:excommunication_war_target = { is_alive = yes } }
		custom_tooltip = { text = tooltip_coronation_depose_excommunicate }
		show_portrait = event_target:excommunication_war_target
		set_character_flag = flag_excommunicated_for_coronation 
		hidden_tooltip = { 
			event_target:excommunication_war_target = { 
				character_event = { id = HF.20218 } #Ping to potential target. 
			}
		}
		#hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event - # Not this time, it'll be fired on_success of the war.
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20214
		trigger = { event_target:excommunication_war_target = { is_alive = yes } }
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_excommunication_war
				years = 10
				who = ROOT
			}
		}
		ai_chance = { factor = 0 }
	}
	option = {
		name = EVTOPTAHF20212
		trigger = { NOT = { event_target:excommunication_war_target = { is_alive = yes } } } #In the event of target being invalidated.
		hidden_tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = { 
			limit = { real_tier = KING }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 } 
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = { 
			limit = { real_tier = EMPEROR }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 } 
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20212
		trigger = { NOT = { event_target:excommunication_war_target = { is_alive = yes } } } #In the event of target being invalidated.
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#King: Pope wants an Antipope deposed.
letter_event = {
	id = HF.20215
	desc = {
		text = EVTDESCHFA20215
		trigger = { 
			event_target:antipapal_war_target = { is_alive = yes }
		}
	}
	desc = { #If target has been invalidated in the meantime for whatever reason, default to money donation.
		text = EVTDESCHFA20212
		trigger = { 
			NOT = { event_target:antipapal_war_target = { is_alive = yes } }
		}
	}
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	immediate = { 
		random_independent_ruler = { 
			limit = {
				religion = FROM
				NOT = { is_allied_with = FROM }
				is_within_diplo_range = ROOT
				OR = {
					religion = catholic
					religion = fraticelli
				}
				rightful_religious_head_scope = {
					is_liege_or_above = PREV
					OR = {
						has_claim = k_papal_state
						has_claim = d_fraticelli
					}
				}
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 50 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 100 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 150 } } 
				NOT = { relative_power = { who = ROOT power = 2 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 50 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 100 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { distance_from_realm = { who = ROOT value = 150 } } 
				NOT = { relative_power = { who = ROOT power = 3 } }
			}
			preferred_limit = { 
				NOT = { relative_power = { who = ROOT power = 4 } }
			}
		save_event_target_as = antipapal_war_target 
		}
	}
	option = {
		name = EVTOPTAHF20215
		trigger = { event_target:antipapal_war_target = { is_alive = yes } }
		custom_tooltip = { text = tooltip_coronation_depose_antipope }
		set_character_flag = flag_antipope_for_coronation
		show_portrait = event_target:antipapal_war_target
		hidden_tooltip = { 
			event_target:antipapal_war_target = { 
			character_event = { id = HF.20218 } #Ping to potential target. 
			}
		}
		#hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event - #Not this time, it'll be fired on_success of the war.
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20215
		trigger = { event_target:antipapal_war_target = { is_alive = yes } }
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_antipope_war
				years = 10
				who = ROOT
			}
		}
		ai_chance = { factor = 0 }
	}
	option = {
		name = EVTOPTAHF20212
		trigger = { NOT = { event_target:antipapal_war_target = { is_alive = yes } } } #In the event of target being invalidated.
		hidden_tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = { 
			limit = { real_tier = KING }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 } 
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = { 
			limit = { real_tier = EMPEROR }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 } 
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20212
		trigger = { NOT = { event_target:antipapal_war_target = { is_alive = yes } } } #In the event of target being invalidated.
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#Emperor: Pope wants a piece of Italy.
letter_event = {
	id = HF.20216
	desc = EVTDESCHFA20216
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	immediate = {

	}
	option = {
		name = EVTOPTAHF20216
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		#First of all, if the Emperor has Rome, it is asked automatically as an additional gift.
		#Latium Check
		if  = { 
			limit = { has_landed_title = c_roma }
			c_roma = { 
				grant_title = FROM 
				any_de_jure_vassal = { #Pope vassalizes all vassal titles in the scope
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } } 
				}
				any_de_jure_vassal_title = { #Pope takes over any titles under the title he's taking over from you.
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
		}
		#Secondly, check for all Duchies within the borders of the historical Donation of Pepin (Latium, Spoleto, Ancona, Ferrara, Benevento).
		#If the Emperor owns them directly, the Pope takes the title, if his vassals do, said vassals will become the Papacy's vassals.
		#Latium Check
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					title = d_latium
				}
			}
			d_latium = { 
				grant_title = FROM 
				any_de_jure_vassal = {
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
				}
				any_de_jure_vassal_title = {
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
			break = yes
		}
		if  = { 
			limit = {
				any_vassal = {
					lower_tier_than = FROM
					any_demesne_title = {
						#can_be_given_away = yes #No need as he will only get vassalized.
						tier = duke
						title = d_latium
					}
				}
			}
			random_vassal = { 
				limit = { 
					has_landed_title = d_latium
					lower_tier_than = FROM
				} 
				set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
			}
			break = yes
		}
		#Spoleto Check
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					title = d_spoleto
				}
			}
			d_spoleto = { 
				grant_title = FROM 
				any_de_jure_vassal = {
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
				}
				any_de_jure_vassal_title = {
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
			break = yes
		}
		if  = { 
			limit = {
				any_vassal = {
					lower_tier_than = FROM
					any_demesne_title = {
						#can_be_given_away = yes
						tier = duke
						title = d_spoleto
					}
				}
			}
			random_vassal = { 
				limit = { 
					has_landed_title = d_spoleto 
					lower_tier_than = FROM
				} 
				set_defacto_liege = FROM
				hidden_tooltip = { character_event =  { id = HF.20230 } }
			}
			break = yes
		}
		#Ancona Check
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					title = d_ancona
				}
			}
			d_ancona = { 
				grant_title = FROM 
				any_de_jure_vassal = {
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
				}
				any_de_jure_vassal_title = {
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
			break = yes
		}
		if  = { 
			limit = {
				any_vassal = {
					lower_tier_than = FROM
					any_demesne_title = {
						#can_be_given_away = yes 
						tier = duke
						title = d_ancona
					}
				}
			}
			random_vassal = { 
				limit = { 
					has_landed_title = d_ancona 
					lower_tier_than = FROM
				} 
				set_defacto_liege = FROM
				hidden_tooltip = { character_event =  { id = HF.20230 } }
			}
			break = yes
		}
		#Ferrara
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					title = d_ferrara
				}
			}
			d_ferrara = { 
				grant_title = FROM 
				any_de_jure_vassal = {
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
				}
				any_de_jure_vassal_title = {
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
			break = yes
		}
		if  = { 
			limit = {
				any_vassal = {
					lower_tier_than = FROM
					any_demesne_title = {
						#can_be_given_away = yes 
						tier = duke
						title = d_ferrara
					}
				}
			}
			random_vassal = { 
				limit = { 
					has_landed_title = d_ferrara 
					lower_tier_than = FROM
				} 
				set_defacto_liege = FROM
				hidden_tooltip = { character_event =  { id = HF.20230 } }
			}
			break = yes
		}
		#Benevento
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					title = d_benevento
				}
			}
			d_benevento = { 
				grant_title = FROM 
				any_de_jure_vassal = {
					limit = { 
						vassal_of = ROOT 
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = FROM
					hidden_tooltip = { character_event =  { id = HF.20230 } }
				}
				any_de_jure_vassal_title = {
					limit = { owner =  { character = ROOT } }
					grant_title = FROM
				} 
			}
			break = yes
		}
		if  = { 
			limit = {
				any_vassal = {
					lower_tier_than = FROM
					any_demesne_title = {
						#can_be_given_away = yes 
						tier = duke
						title = d_benevento
					}
				}
			}
			random_vassal = { 
				limit = { 
					has_landed_title = d_benevento 
					lower_tier_than = FROM
				} 
				set_defacto_liege = FROM
				hidden_tooltip = { character_event =  { id = HF.20230 } }
			}
			break = yes
		}
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20216
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_papal_land
				years = 10
				who = ROOT
			}
		}
		ai_chance = { factor = 0 }
	}
}

#Emperor: Pope wants you to give a Duchy to a Holy Order.
letter_event = {
	id = HF.20217
	desc = {
		text = EVTDESCHFA20217
		trigger = { 
			has_landed_title = event_target:scoped_duchy
		}
	}
	desc = { #If target duchy has been invalidated in the meantime for whatever reason, default to money donation.
		text = EVTDESCHFA20212
		trigger = { 
			NOT = { has_landed_title = event_target:scoped_duchy }
		}
	}
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes

	immediate = {
		#Check if there is an available bordering province, in order to limit bordergore.
		if  = { 
			limit = {
				any_demesne_title = {
					can_be_given_away = yes
					tier = duke
					any_direct_de_jure_vassal_title = {
						location = {
							any_neighbor_province = {
								has_owner = yes
								owner = {
									NOR = {
										character = ROOT
										is_liege_or_above = ROOT
									}
								}
							}
						}
					}
				}
			}
			random_demesne_title = {
				limit = {
					can_be_given_away = yes
					tier = duke
					any_direct_de_jure_vassal_title = {
						location = {
							any_neighbor_province = {
								has_owner = yes
								owner = {
									NOR = {
										character = ROOT
										is_liege_or_above = ROOT
									}
								}
							}
						}
					}
				}
				preferred_limit = { #Try to give them counties as well.
					any_de_jure_vassal_title = {
						owner =  { character = ROOT } 
					}
				}
				save_event_target_as = scoped_duchy
			}
		}
		#Otherwise pick random demesne Duchy.
		else = {
			random_demesne_title = {
				limit = { 
					can_be_given_away = yes
					tier = duke
				}
				preferred_limit = { #Try to give them counties as well.
					any_de_jure_vassal_title = {
						owner =  { character = ROOT } 
					}
				}
			}
			save_event_target_as = scoped_duchy
		}
		random_playable_ruler = { 
			limit = { 
				religion = ROOT
				OR = { 
					has_landed_title = d_knights_templar
					has_landed_title = d_teutonic_order
					has_landed_title = d_knights_hospitaler
					has_landed_title = d_knights_santiago
					has_landed_title = d_knights_calatrava 
				} 
			}
			save_event_target_as = scoped_grandmaster
		}
	}
	
	option = {
		name = EVTOPTAHF20217
		trigger = { has_landed_title = event_target:scoped_duchy }
		set_character_flag = flag_crowned_by_pope
		show_portrait = event_target:scoped_grandmaster
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		#Make sure both targets exist, otherwise randomize.
		if = { 
			limit = { 
				has_landed_title = event_target:scoped_duchy
				event_target:scoped_grandmaster = { is_alive = yes }
			}
			event_target:scoped_duchy = {
				grant_title = event_target:scoped_grandmaster 		#Grant the Duchy
				any_de_jure_vassal = {		#Transfer vassals under the Duchy
					limit = { 
						vassal_of = ROOT 
						lower_tier_than = event_target:scoped_grandmaster
						NOT = { owner =  { character = ROOT } } 
					}
					set_defacto_liege = event_target:scoped_grandmaster
				} 
				any_de_jure_vassal_title = { 	#Take over dejure titles under the Duchy
					limit = { owner =  { character = ROOT }  }
					grant_title = event_target:scoped_grandmaster
				}
			}
		}
		else = { 
		#If the player is being sneaky or the Grandmaster dies in the meantime, pick another duchy.
			random_playable_ruler = { 
				limit = { 
					religion = ROOT
					OR = { 
						has_landed_title = d_knights_templar
						has_landed_title = d_teutonic_order
						has_landed_title = d_knights_hospitaler
						has_landed_title = d_knights_santiago
						has_landed_title = d_knights_calatrava 
					} 
				}
				ROOT = {
					random_demesne_title = {
						limit = { 
							can_be_given_away = yes
							tier = duke
						}
						grant_title = PREVPREV 
						any_de_jure_vassal = {
							limit = { 
								vassal_of = ROOT 
								lower_tier_than = PREVPREVPREV
								NOT = { owner =  { character = ROOT } } 
							}
							set_defacto_liege = PREVPREVPREV
						} 
						any_de_jure_vassal_title = {
							limit = { owner =  { character = ROOT } }
							grant_title = PREVPREVPREV
						}
					}
				}
			}
		}
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20217
		trigger = { has_landed_title = event_target:scoped_duchy }
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = {
				show_scope_change = no	 
			opinion = {
				modifier = opinion_requested_land_holyorder
				years = 10
				who = ROOT
			}
		}
		ai_chance = { factor = 0 }
	}
	option = {
		name = EVTOPTAHF20212
		trigger = { NOT = { has_landed_title = event_target:scoped_duchy } } #In the event of target being invalidated.
		hidden_tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = { 
			limit = { real_tier = KING }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 } 
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = { 
			limit = { real_tier = EMPEROR }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 } 
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20212
		trigger = { NOT = { has_landed_title = event_target:scoped_duchy } } #In the event of target being invalidated.
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#Ping to Excommunicated ruler/liege of antipope, prepare for war.
character_event = {
	id = HF.20218
	desc = {
		trigger = {
			FROM = { has_character_flag = flag_excommunicated_for_coronation }
		}
		text = EVTDESCHFA20218
	}
	desc = {
		trigger = {
			FROM = { has_character_flag = flag_antipope_for_coronation }
		}
		text = EVTDESCHFB20218
	}

	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = { FROM = { character_event = { id = HF.20219 } } }
	
	option = {
		name = EVTOPTAHF20218
		if = {
			limit = { 
				FROM = { 
					has_character_flag = flag_excommunicated_for_coronation
				} 
			}
			opinion = {
				who = FROM
				modifier = opinion_promsied_to_depose_me
				months = 120
			}
			FROM = {
				opinion = {
					who = ROOT
					modifier = opinion_promsied_to_depose_him
					months = 120
				}
			}
		}
		if = {
			limit = { 
				FROM = { 
					has_character_flag = flag_antipope_for_coronation 
				} 
			}
			opinion = {
				who = FROM
				modifier = opinion_promsied_to_depose_myantipope
				months = 120
			}
			FROM = {
				opinion = {
					who = ROOT
					modifier = opinion_promsied_to_depose_hisantipope
					months = 120
				}
			}
		}
	}
}

#Back to uncrowned King, start the war.
character_event = {
	id = HF.20219
	desc = {
		trigger = {
			has_character_flag = flag_excommunicated_for_coronation
		}
		text = EVTDESCHFA20219
	}
	desc = {
		trigger = {
			has_character_flag = flag_antipope_for_coronation
		}
		text = EVTDESCHFB20219
	}

	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = { 
		if = {
			limit = { has_character_flag = flag_excommunicated_for_coronation }
			FROM = {
				reverse_war = {
					target = ROOT
					casus_belli = excommunicated_ruler
				}
			}
		}
		if = {
			limit = { has_character_flag = flag_antipope_for_coronation }
			FROM = {
				reverse_war = {
					target = ROOT
					casus_belli = depose_antipope
				}
			}
		}
	}
	
	option = {
		name = EVTOPTAHF20219
		tooltip = {
			if = {
				limit = { has_character_flag = flag_excommunicated_for_coronation } 
				reverse_opinion = {
					who = FROM
					modifier = opinion_promsied_to_depose_me
					months = 120
				}
				FROM = {
				show_scope_change = no	
					reverse_opinion = {
						who = ROOT
						modifier = opinion_promsied_to_depose_him
						months = 120
					}
				}
			}
			if = {
				limit = { has_character_flag = flag_antipope_for_coronation } 
				reverse_opinion = {
					who = FROM
					modifier = opinion_promsied_to_depose_myantipope
					months = 120
				}
				FROM = {
				show_scope_change = no	
					reverse_opinion = {
						who = ROOT
						modifier = opinion_promsied_to_depose_hisantipope
						months = 120
					}
				}
			}
		}
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
	}
}

#On_success of Excommunication/Antipope CB: congratulate with ruler, resume the coronation event chain.
character_event = {
	id = HF.20220
	desc = {
		trigger = {
			has_character_flag = flag_excommunicated_for_coronation
		}
		text = EVTDESCHFA20220
	}
	desc = {
		trigger = {
			has_character_flag = flag_antipope_for_coronation
		}
		text = EVTDESCHFB20220
	}

	trigger = { higher_real_tier_than = DUKE } #In case the first ruler dies or loses his Coronation-worthy tier before the war is won.

	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20220
		set_character_flag = flag_preparing_coronation #Set it back to avoid the decision from being available again.
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		set_character_flag = flag_crowned_by_pope
		religion_head = {  #otherwise the scope would have been lost.
			save_event_target_as = coronation_priest
				show_scope_change = no	 
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
	}
}

#King: Pope wants you to wage Holy War on his behalf.
letter_event = {
	id = HF.20221
	desc = {
		text = EVTDESCHFA20221
		trigger = { 
			event_target:papal_war_target = { is_alive = yes }
		}
	}
	desc = { #If target has been invalidated in the meantime for whatever reason, default to money donation.
		text = EVTDESCHFA20212
		trigger = { 
			NOT = { event_target:papal_war_target = { is_alive = yes } }
		}
	}
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	immediate = { 
		if = { 
			limit = { 
				any_independent_ruler = { 
					is_within_diplo_range = ROOT
					NOT = { religion_group = FROM }
					NOT = { is_allied_with = FROM }
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
			} 
			random_independent_ruler = { 
				limit = {
					is_within_diplo_range = ROOT
					NOT = { is_allied_with = FROM }
					NOT = { religion_group = FROM }
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
				save_event_target_as = papal_war_target
			}
		}
		#Then for heretics
		else_if = { 
			limit = { 
				any_independent_ruler = { 
					is_within_diplo_range = ROOT
					is_heresy_of = FROM
					NOT = { is_allied_with = FROM }
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
			} 
			random_independent_ruler = { 
				limit = {
					is_within_diplo_range = ROOT
					is_heresy_of = FROM
					NOT = { is_allied_with = FROM }
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
				save_event_target_as = papal_war_target
			}
		}
		#Then for disliked Catholics/Fraticelli
		else_if = { 
			limit = { 
				any_independent_ruler = { 
					is_within_diplo_range = ROOT
					NOT = { is_allied_with = FROM }
					religion = FROM
					is_theocracy = no
					FROM = { 
						NOT = { 
							opinion = { 
								who = PREV
								value = -50
							}
						}
					}
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
			} 
			random_independent_ruler = { 
				limit = {
					is_within_diplo_range = ROOT
					religion = FROM
					NOT = { is_allied_with = FROM }
					is_theocracy = no
					FROM = { 
						NOT = { 
							opinion = { 
								who = PREV
								value = -50
							}
						}
					}
					OR = {
						any_demesne_title = {
							OR = {
								title = d_latium
								title = d_spoleto
								title = d_ancona
								title = d_ferrara
								title = d_benevento
								d_latium = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_spoleto = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ancona = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_ferrara = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
								d_benevento = {
									any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
								}
							}
						}
						any_vassal = {
							any_demesne_title = {
								OR = {
									title = d_latium
									title = d_spoleto
									title = d_ancona
									title = d_ferrara
									title = d_benevento
									d_latium = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_spoleto = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ancona = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_ferrara = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
									d_benevento = {
										any_de_jure_vassal_title = { owner = { character = PREVPREVPREVPREV } }
									}
								}
							}
						}
					}
				}
				save_event_target_as = papal_war_target
			}
		}
	}
	
	option = {
		name = EVTOPTAHF20221
		trigger = { event_target:papal_war_target = { is_alive = yes } }
		custom_tooltip = { text = tooltip_coronation_pepin_war }
		show_portrait = event_target:papal_war_target
		set_character_flag = flag_pepin_for_coronation
		hidden_tooltip = { 
			event_target:papal_war_target = { character_event = { id = HF.20222 } } #Ping to potential target.
		}
		#hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event - #Not this time, it'll be fired on_success of the war.
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20221
		trigger = { event_target:papal_war_target = { is_alive = yes } }
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
			show_scope_change = no	
			opinion = {
				modifier = opinion_requested_pepin_war
				years = 10
				who = ROOT
			}
		}
		ai_chance = { factor = 0 }
	}
	option = {
		name = EVTOPTAHF20212
		trigger = { NOT = { event_target:papal_war_target = { is_alive = yes } } } #In the event of target being invalidated.
		hidden_tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_coronation_money_refund
					who = ROOT
					years = 100
				}
			}
		}
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - King tier
		if = { 
			limit = { real_tier = KING }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2 min = 600 max = 1200 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 500 max = 900 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 400 max = 750 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.0 min = 350 max = 600 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 500 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 250 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 200 max = 350 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.65 min = 175 max = 300 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.5 min = 150 max = 250 } 
			}
		}
		#Transfer scaled wealth based on Pope's opinion of you and your piety. - Emperor tier
		if = { 
			limit = { real_tier = EMPEROR }
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 3 min = 950 max = 1750 } 
			}
			if = { 
				limit = {
					piety = 350
					FROM = { 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -75
							} 
						}
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.5 min = 750 max = 1500 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 2.0 min = 600 max = 1000 } 
			}
			if = { 
				limit = {  
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -75
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = -25
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.75 min = 500 max = 850 } 
			}
			if = { 
				limit = {  
					NOT = { 
						piety = 350
					} 
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.5 min = 450 max = 700 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = -25
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 0
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.35 min = 400 max = 600 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}  
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 1.25 min = 350 max = 500 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 0
						} 
						NOT = { 
							opinion = { 
								who = ROOT 
								value = 50
							} 
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.95 min = 300 max = 450 } 
			}
			if = { 
				limit = { 
					NOT = { 
						piety = 350
					}   
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.85 min = 275 max = 400 } 
			}
			if = { 
				limit = { 
					piety = 350
					FROM = { 
						opinion = { 
							who = ROOT 
							value = 50
						} 
					} 
				} 
				transfer_scaled_wealth = { to = FROM value = 0.75 min = 250 max = 350 } 
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20212
		trigger = { NOT = { event_target:papal_war_target = { is_alive = yes } } }#In the event of target being invalidated.
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#Ping to target owner of papal land, prepare for war.
character_event = {
	id = HF.20222
	desc = {
		trigger = {
			NOT  = { religion = FROMFROM }
		}
		text = EVTDESCHFA20222
	}
	desc = {
		trigger = {
			religion = FROMFROM
		}
		text = EVTDESCHFB20222
	}


	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = { 
		#Long check to determine which title will be the subject of the war. If the selected target has more than one title, the one most dear to the Pope will be prioritized.
		########################################################################################
		#Check if the target or one of his vassals own one of the possible target Duchies or any land within their dejure.
		if = { 
			limit = {  
				OR = {
					#Check whether you (or your vassals) own the title directly...
					has_landed_title = d_latium
					any_vassal = { has_landed_title = d_latium }
					#...or if you (or your vassals) only own land within the title's dejure.
					d_latium = {
						any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
					}
					any_vassal = { 
						d_latium = {
							any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
						}
					}
				}
			}
			d_latium = { save_event_target_as = pepin_title_target }
			FROM = { character_event = { id = HF.20223 } }
		}
		else_if = { 
			limit = {  
				OR = {
					#Check whether you (or your vassals) own the title directly...
					has_landed_title = d_spoleto
					any_vassal = { has_landed_title = d_spoleto }
					#...or if you (or your vassals) only own land within the title's dejure.
					d_spoleto = {
						any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
					}
					any_vassal = { 
						d_spoleto = {
							any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
						}
					}
				}
			}
			d_spoleto = { save_event_target_as = pepin_title_target }
			FROM = { character_event = { id = HF.20223 } }
		}
		else_if = { 
			limit = {  
				OR = {
					#Check whether you (or your vassals) own the title directly...
					has_landed_title = d_ancona
					any_vassal = { has_landed_title = d_ancona }
					#...or if you (or your vassals) only own land within the title's dejure.
					d_ancona = {
						any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
					}
					any_vassal = { 
						d_ancona = {
							any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
						}
					}
				}
			}
			d_ancona = { save_event_target_as = pepin_title_target }
			FROM = { character_event = { id = HF.20223 } }
		}
		else_if = { 
			limit = {  
				OR = {
					#Check whether you (or your vassals) own the title directly...
					has_landed_title = d_ferrara
					any_vassal = { has_landed_title = d_ferrara }
					#...or if you (or your vassals) only own land within the title's dejure.
					d_ferrara = {
						any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
					}
					any_vassal = { 
						d_ferrara = {
							any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
						}
					}
				}
			}
			d_ferrara = { save_event_target_as = pepin_title_target }
			FROM = { character_event = { id = HF.20223 } }
		}
		else_if = { 
			limit = {  
				OR = {
					#Check whether you (or your vassals) own the title directly...
					has_landed_title = d_benevento
					any_vassal = { has_landed_title = d_benevento }
					#...or if you (or your vassals) only own land within the title's dejure.
					d_benevento = {
						any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
					}
					any_vassal = { 
						d_benevento = {
							any_de_jure_vassal_title = { owner = { character = PREVPREVPREV } }
						}
					}
				}
			}
			d_benevento = { save_event_target_as = pepin_title_target }
			FROM = { character_event = { id = HF.20223 } }
		}
	}
	
	option = {
		name = EVTOPTAHF20222
	}
}

#Back to uncrowned Emperor, start the war.
character_event = {
	id = HF.20223
	desc = EVTDESCHFA20223

	picture = GFX_evt_crusaders
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	immediate = { 
		FROM = {
			reverse_unsafe_war = {
				target = ROOT
				casus_belli = pepin_religious
				thirdparty_title = event_target:pepin_title_target
			}
		}
	}
	
	option = {
		name = EVTOPTAHF20223
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		tooltip = {
			FROM = {
				reverse_war = {
					target = ROOT
					casus_belli = pepin_religious
					thirdparty_title = event_target:pepin_title_target
				}
			}
		}
	}
}

#On_victory: Emperor praised for giving land to the Pope
character_event = {
	id = HF.20224
	desc = {
		trigger = {
			NAND  = { 
				has_character_flag = flag_pepin_for_coronation
				higher_real_tier_than = DUKE 
			}
			NOT = { has_character_flag = flag_pope_gifts_artifact }
		}
		text = EVTDESCHFA20224
	}
	desc = {
		trigger = { #Special description if you waged the war for coronation.
			has_character_flag = flag_pepin_for_coronation
			higher_real_tier_than = DUKE
			NOT = { has_character_flag = flag_pope_gifts_artifact }
		}
		text = EVTDESCHFB20224
	}
	desc = {
		trigger = {
			NAND  = { 
				has_character_flag = flag_pepin_for_coronation 
				higher_real_tier_than = DUKE
			}
			has_character_flag = flag_pope_gifts_artifact
		}
		text = EVTDESCHFC20224
	}
	desc = {
		trigger = { #Special description if you waged the war for coronation.
			has_character_flag = flag_pepin_for_coronation
			has_character_flag = flag_pope_gifts_artifact
			higher_real_tier_than = DUKE
		}
		text = EVTDESCHFD20224
	}

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20224
		if = { 
			limit = { has_character_flag = flag_pope_gifts_artifact } 
			religion_head = { 
				show_scope_change = no	 
				random_artifact = { 
					limit = {
						has_artifact_flag = christian
						NOR =  { 
							has_artifact_flag = very_rare
							has_artifact_flag = unique #Won't give the holiest ones away.
						}
					}
					transfer_artifact = {
						to = ROOT
						from = PREV
					} 
				}
			}
		}
		clr_character_flag = flag_pope_gifts_artifact
		if = { 
			limit = { 
				has_character_flag = flag_pepin_for_coronation
				higher_real_tier_than = DUKE #In case the first ruler loses his Coronation-worthy tier before the war is won.
			}
			clr_character_flag = flag_pepin_for_coronation
			set_character_flag = flag_preparing_coronation
			set_character_flag = flag_crowned_by_pope
			religion_head = {  #otherwise the scope would have been lost.
				save_event_target_as = coronation_priest 
				show_scope_change = no	
				reverse_opinion = {
					modifier = opinion_supposed_to_crown
					months = 1
					who = ROOT
				}
				opinion = {
					modifier = opinion_supposed_to_crown
					months = 1
					who = ROOT
				}
			}
			hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		}
	}
}

#Emperor: Crazy Pope wants the Empire.
letter_event = {
	id = HF.20225
	desc = EVTDESCHFA20225
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20225
		FROM = { make_tributary = { who = ROOT tributary_type = permanent } }
		hidden_tooltip = { character_event = { id = HF.20226 } }
		ai_chance = { 
			factor = 80 
			modifier = {
				factor = 0.1
				NOR = {
					trait = zealous
					trait = lunatic
					trait = possessed
				}
			}
		}
	}
	option = {	#End of the line
		name = EVTOPTBHF20225
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
			show_scope_change = no	
			opinion = {
				modifier = opinion_requested_papal_land
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 
			factor = 20 
		}
	}
}

#Follow-up event about Emperor bowing to the Pope.
character_event = {
	id = HF.20226
	desc = EVTDESCHFA20226

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20226
		set_character_flag = flag_crowned_by_pope
		religion_head = {  #otherwise the scope would have been lost.
			save_event_target_as = coronation_priest 
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
	}
}

#On_death chain: if a Character dies while during a war started as part of a deal for a coronation, his heir will inherit the flag, and be crowned at the end.
character_event = {
	id = HF.20227
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_antipope_for_coronation 

	trigger = {
		any_war = {
			using_cb = depose_antipope
		}
	}

	immediate = {
		current_heir = { 
			set_character_flag = flag_antipope_for_coronation 
			character_event = { id = HF.20418 days = 2 } #Further safety check.
		}
	}
}

#On_death chain: if a Character dies while during a war started as part of a deal for a coronation, his heir will inherit the flag, and be crowned at the end.
character_event = {
	id = HF.20228
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_excommunicated_for_coronation  

	trigger = {
		any_war = {
			using_cb = excommunicated_ruler
		}
	}

	immediate = {
		current_heir = { 
			set_character_flag = flag_excommunicated_for_coronation 
			character_event = { id = HF.20419 days = 2 } #Further safety check.
		}
	}
}

#On_death chain: if a Character dies while during a war started as part of a deal for a coronation, his heir will inherit the flag, and be crowned at the end.
character_event = {
	id = HF.20229
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_pepin_for_coronation   

	trigger = {
		any_war = {
			using_cb = pepin_religious
		}
	}

	immediate = {
		current_heir = { set_character_flag = flag_pepin_for_coronation
			character_event = { id = HF.20420 days = 2 } #Further safety check.
		}
	}
}

#Notification: Vassal, you've just become a Papal vassal.
character_event = {
	id = HF.20230
	desc = EVTDESCHFA20230

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20230
	}
}

#On_death of the coronation_priest. Set hidden opinion to ping back to the coronation_ruler.
character_event = {
	id = HF.20231
	hide_window = yes
	is_triggered_only = yes

	only_rulers = yes
	min_age = 16

	trigger = {
		has_any_opinion_modifier = opinion_supposed_to_crown
	}

	immediate = {
		any_playable_ruler = { 
			limit = { 
				has_opinion_modifier = { 
					who = ROOT 
					modifier = opinion_supposed_to_crown 
				}
			}
			character_event = { id = HF.20232 }
		}
	}
}

#King to be crowned: your coronation_priest has died. The ceremony is cancelled.
character_event = {
	id = HF.20232
	desc = EVTDESCHFA20232

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20232
		hidden_tooltip = { remove_trait = travelling }
		hidden_tooltip = { remove_character_modifier = out_traveling }
		hidden_tooltip = { set_variable = { which = coronation_count value = 0 } }
		clr_character_flag = flag_preparing_coronation #Still used when after waging wars
		clr_character_flag = flag_antipope_for_coronation 
		clr_character_flag = flag_excommunicated_for_coronation 
		clr_character_flag = flag_pepin_for_coronation 
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent 
		clr_character_flag = flag_coronation_gain_ambitious 
		clr_character_flag = flag_coronation_haughty_child 
		clr_character_flag = flag_coronation_priest_approves 
		clr_character_flag = flag_coronation_hre_talk 
		clr_character_flag = flag_coronation_pope_talk 
		clr_character_flag = flag_coronation_foreign_teacher 
		clr_character_flag = flag_coronation_priest_disapproves 
		clr_character_flag = flag_coronation_diplomatic_incident 
		clr_character_flag = flag_coronation_cynic_taunts 
		clr_character_flag = flag_coronation_wandering_knight 
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry 
		clr_character_flag = flag_coronation_secluded_embarassed 
		clr_character_flag = flag_coronation_secluded_vassals 
		clr_character_flag = flag_coronation_secluded_priest 
		clr_character_flag = flag_coronation_secluded_ambitious 
		clr_character_flag = flag_coronation_secluded_proud 
		clr_character_flag = flag_coronation_secluded_steward 


		hidden_tooltip = { 
			any_playable_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
				}
				remove_trait = travelling
				remove_opinion = { 
					who = ROOT
					modifier = opinion_coronation_guest 
				}
				character_event = { id = HF.20233 }
			} 
			any_courtier_or_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
				}
				remove_trait = travelling
				remove_opinion = { 
					who = ROOT
					modifier = opinion_coronation_guest 
				}
				character_event = { id = HF.20233 }
			}
		}
	}
}

#Guest: King to be crowned lost coronation_priest. Coronation has been cancelled.
character_event = {
	id = HF.20233
	desc = EVTDESCHFA20233

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20233
	}
}
#Hidden event to make pope independent upon request.
character_event = {
	id = HF.20234
	hide_window = yes 

	is_triggered_only = yes

	immediate = {
		set_defacto_liege = THIS
	}
}

#King: Pope wants an orgy.
letter_event = {
	id = HF.20235
	desc = EVTDESCHFA20235
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	#Fund AND join the Orgy
	option = {
		name = EVTOPTZHF20235
		custom_tooltip = { text = join_pope_orgy }
		set_character_flag = flag_crowned_by_pope
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
		}
		transfer_scaled_wealth = { to = FROM value = 0.75 min = 150 max = 400 } 
		tiered_piety_negative_effect = yes
		hidden_tooltip = { 
			FROM = { 
				tiered_piety_negative_effect = yes
			} 
		}
		hidden_tooltip = { character_event = { id = HF.20236 } } #Small event chain.
		#hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 10 }
	}
	option = {
		name = EVTOPTAHF20235
		trigger = { NOT = { trait = hedonist } }
		set_character_flag = flag_crowned_by_bishop
		FROM = { save_event_target_as = coronation_priest
				show_scope_change = no	
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 2
				who = ROOT
			}
		}
		transfer_scaled_wealth = { to = FROM value = 0.75 min = 150 max = 400 } 
		piety = -50
		hidden_tooltip = { 
			FROM = { 
				tiered_piety_negative_effect = yes
			} 
		}
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20235
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

#Go to the priest's orgy, because why not.
character_event = {
	id = HF.20236
	desc = { #Orgy with Prince-Bishop.
		text = EVTDESCHFA20236
		trigger = {
			NOT = {
				FROMFROM = { 
					has_landed_title = k_papal_state
				}
			}
		}
	}
	desc = { #Orgy with the Pope.
		text = EVTDESCHFB20236
		trigger = {
			FROMFROM = { 
				has_landed_title = k_papal_state
			}
		}
	}
	show_from_from = yes

	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20236
		custom_tooltip = { text = papal_orgy_drunk }
		set_character_flag = flag_papal_orgy_drunk
		if = { 
			limit = { trait = drunkard } 
			tiered_piety_negative_effect = yes
		}
		if = { 
			limit = { NOT = { trait = drunkard } } 
			add_trait = drunkard 
		}
		if = { 
			limit = { FROMFROM = { has_landed_title = k_papal_state } } 
			prestige = 50
		}
		ai_chance = { factor = 30 }
	}
	option = {
		name = EVTOPTBHF20236
		custom_tooltip = { text = papal_orgy_lustful }
		set_character_flag = flag_papal_orgy_lustful
		if = { 
			limit = { trait = lustful } 
			tiered_piety_negative_effect = yes
		}
		if = { 
			limit = { trait = chaste } 
			remove_trait = chaste
		}
		if = { 
			limit = { NOT = { trait = lustful } } 
			add_trait = lustful
		}
		if = { 
			limit = { FROMFROM = { has_landed_title = k_papal_state } } 
			prestige = 50
		}
		ai_chance = { factor = 30 }
	}
	option = {
		name = EVTOPTCHF20236
		custom_tooltip = { text = papal_orgy_glutton }
		set_character_flag = flag_papal_orgy_glutton
		if = { 
			limit = { trait = gluttonous } 
			tiered_piety_negative_effect = yes
		}
		if = { 
			limit = { trait = temperate } 
			remove_trait = temperate
		}
		if = { 
			limit = { NOT = { trait = gluttonous } } 
			add_trait = gluttonous
		}
		if = { 
			limit = { FROMFROM = { NOT = { has_landed_title = k_papal_state } } } 
			gain_weight_medium_effect = yes
			weight_trait_check_effect = yes
		}
		if = { 
			limit = { FROMFROM = { has_landed_title = k_papal_state } } 
			gain_weight_large_effect = yes
			weight_trait_check_effect = yes
		}
		if = { 
			limit = { FROMFROM = { has_landed_title = k_papal_state } } 
			prestige = 50
		}
		ai_chance = { factor = 30 }
	}
	after = { 
		hidden_tooltip = { 
			random_list = { 
				40 = { #Priest comes onto you.
					modifier = { 
						factor = 0
						is_female = no 
						FROMFROM = { NOT = { trait = homosexual } } 
					} 
					modifier = { 
						factor = 0.25
						is_female = yes
						age = 45
					}
					modifier = { 
						factor = 0.5
						has_ugly_trait_trigger = yes
					} 
					modifier = { 
						factor = 0.5
						trait = disfigured
					} 
					modifier = { 
						factor = 0.5
						trait = has_bubonic_plague
					} 
					modifier = { 
						factor = 0.5
						trait = inbred
					} 
					modifier = { 
						factor = 1.75
						has_fair_trait_trigger = yes
					} 	
					modifier = { 
						factor = 1.5
						NOT = { age = 30 }
					} 
					modifier = { 
						factor = 2.5
						NOT = { age = 18 } #Obviously...
					} 
					modifier = { 
					factor = 0.5
						trait = one_eyed
					} 
					modifier = { 
						factor = 1.5
						trait = lustful
					} 
					modifier = { 
						factor = 0.5
						FROMFROM = { NOT = { trait = lustful } }
					} 

					character_event = { id = HF.20237 } 
				}
				30 = { #Become Hedonist.
					modifier = { 
						factor = 0
						has_any_lifestyle_trait = yes
					} 
					modifier = { 
						factor = 1.5
						trait = drunkard
					} 
					modifier = { 
						factor = 1.5
						trait = gluttonous
					} 
					modifier = { 
						factor = 1.5
					trait = slothful
					} 
					modifier = { 
						factor = 1.5
						trait = lustful
					} 
					character_event = { id = HF.20238 } 
				}
				30 = { #Nothing happens, end the event.
					character_event = { id = HF.20239 } 
				}
			}
		}
	}
}

#Time for the communion
character_event = {
	id = HF.20237
	desc = { # with Prince-Bishop.
		text = EVTDESCHFA20237
		trigger = {
			NOT = {
				FROMFROMFROM = { 
					has_landed_title = k_papal_state
				}
			}
		}
	}
	desc = { # with the Pope.
		text = EVTDESCHFB20237
		trigger = {
			FROMFROMFROM = { 
				has_landed_title = k_papal_state
			}
		}
	}
	show_from_from_from = yes

	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20237
		trigger = { 
			OR = { 
				is_female = yes 
				trait = homosexual
			} 
		}
		custom_tooltip = { text = papal_orgy_communion }
		tiered_prestige_reward_effect = yes
		tiered_piety_negative_effect = yes
		hidden_tooltip = { 
			if = { 
				limit = { 
					is_female = yes 
					NOT = { age = 40 }
					fertility = 0.4
				}
				random = { 
					chance = 10
					modifier = {
						factor = 0.5
						NOT = { fertility = 0.3 }
					}
					modifier = {
						factor = 1.5
						fertility = 0.3
					}
					modifier = {
						factor = 1.5
						fertility = 0.5
					}
					modifier = {
						factor = 1.5
						fertility = 0.7
					}
					modifier = {
						factor = 1.5
						fertility = 0.9
					}
					modifier = {
						factor = 1.5
						fertility = 1.25
					}
					modifier = {
						factor = 1.75
						fertility = 1.5
					}
					modifier = {
						factor = 2
						fertility = 1.75
					}
					modifier = {
						factor = 3
						fertility = 2
					}
					ROOT = { impregnate = FROMFROMFROM }
					if = { 
						limit = { FROMFROMFROM = { has_landed_title = k_papal_state } } 
						set_character_flag = flag_vatican_prince #cleared on birth.
					}
				}
			}
		}
		hidden_tooltip = { character_event = { id = HF.20239 } } #Conclude the Orgy.
		ai_chance = { 
			factor = 90 
			modifier = { 
				factor = 0.25
				trait = chaste
			}
		}
	}
	option = {
		name = EVTOPTBHF20237
		custom_tooltip = { text = papal_orgy_flee }
		hidden_tooltip = { character_event = { id = HF.20239 } } #Conclude the Orgy.
		ai_chance = { 
			factor = 10 
		}
	}
}

#Becoming Hedonist
character_event = {
	id = HF.20238
	desc = EVTDESCHFA20238
	show_from_from_from = yes

	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20238
		add_trait = hedonist
		hidden_tooltip = { character_event = { id = HF.20239 } } #Proceed with the coronation.
	}
}

#The orgy has concluded.
character_event = {
	id = HF.20239
	desc = { # with Prince-Bishop.
		text = EVTDESCHFA20239
		trigger = {
			NOT = {
				event_target:coronation_priest = { 
					has_landed_title = k_papal_state
				}
			}
		}
	}
	desc = { # with the Pope.
		text = EVTDESCHFB20239
		trigger = {
			event_target:coronation_priest = { 
				has_landed_title = k_papal_state
			}
		}
	}

	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20239
		clr_character_flag = flag_papal_orgy_drunk
		clr_character_flag = flag_papal_orgy_lustful
		clr_character_flag = flag_papal_orgy_glutton
		hidden_tooltip = { character_event = { id = HF.20300 } } #Proceed with the coronation.
	}
}


#King: Bishop asks for small religious artifact.
letter_event = {
	id = HF.20240
	desc = EVTDESCHFA20240
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	immediate = {
		random_artifact = { 
			limit = { 
				has_artifact_flag = christian  
				NOT = { has_artifact_flag = rare } 
				NOT = { has_artifact_flag = very_rare } 
				NOT = { has_artifact_flag = flag_considering_donation } 
			}
			save_event_target_as = scoped_artifact
			set_artifact_flag = flag_considering_donation
		}
	}
	option = {
		name = EVTOPTAHF20240
		set_character_flag = flag_crowned_by_bishop
		FROM = { 
				show_scope_change = no	
			save_event_target_as = coronation_priest
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		event_target:scoped_artifact = {
			transfer_artifact = {
				from = ROOT
				to = FROM
 			} 
			clr_artifact_flag = flag_considering_donation
 		} 
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20240
		custom_tooltip = { text = coronation_canceled }
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		hidden_tooltip = { 
			event_target:scoped_artifact = { 
				clr_artifact_flag = flag_considering_donation
			} 
		}
		ai_chance = { factor = 0 }
	}
}

#King: Pope asks for rare religious artifact.
letter_event = {
	id = HF.20241
	desc = EVTDESCHFA20241
	border = GFX_event_letter_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	immediate = {
		random_artifact = { 
			limit = { 
				has_artifact_flag = christian  
				OR = { 
					has_artifact_flag = very_rare 
					has_artifact_flag = rare 
				} 
				NOT = { has_artifact_flag = flag_considering_donation } 
			}
			save_event_target_as = scoped_artifact
			set_artifact_flag = flag_considering_donation
		}
	}
	option = {
		name = EVTOPTAHF20241
		set_character_flag = flag_crowned_by_pope
		FROM = { 
				show_scope_change = no	
			save_event_target_as = coronation_priest
			opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
			reverse_opinion = {
				modifier = opinion_supposed_to_crown
				months = 1
				who = ROOT
			}
		}
		event_target:scoped_artifact = {
			transfer_artifact = {
				from = ROOT
				to = FROM
 			} 
			clr_artifact_flag = flag_considering_donation
 		} 
		hidden_tooltip = { character_event = { id = HF.20300 } } #Go to budget event
		ai_chance = { factor = 100 }
	}
	option = {	#End of the line
		name = EVTOPTBHF20241
		custom_tooltip = { text = coronation_canceled }
		# The Pope remembers what he wants, cheaty spammy player.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_requested_artifact
				years = 10
				who = ROOT
			}
		}
		hidden_tooltip = { 
			event_target:scoped_artifact = { 
				clr_artifact_flag = flag_considering_donation
			} 
		}
		#clr_character_flag = flag_preparing_coronation #Replaced by timed modifier
		ai_chance = { factor = 0 }
	}
}

########################################################################################################################################

####Coronation sponsor found, now decide how much money to invest in it. (REVISED WITH SCALED WEALTH)
character_event = {
	id = HF.20300
	desc = {
		trigger = {
			OR = { 
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope 
			}
			war = no
		}
		text = EVTDESCHFA20300
	}
	desc = {
		trigger = {
			has_character_flag = flag_crowned_by_priest
			war = no
		}
		text = EVTDESCHFB20300
	}
	desc = {
		trigger = {
			war = yes
		}
		text = EVTDESCHFC20300
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_religion

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
	}
	is_triggered_only = yes
	
	immediate = {
		save_event_target_as = coronation_ruler
		add_character_modifier = {
			name = out_traveling
			duration = 66
			hidden = yes #Make the character inaccessible, the ruler himself is not actually out, he's still at court.
		}
	}

	option = {
		name = EVTOPTAHF20300
		trigger = { war = no }
		set_character_flag = flag_extravagant_coronation
		custom_tooltip = { text = send_extracoronation_invitations }
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -1 min = -250 max = -1000 }
		}
		hidden_tooltip = {
			character_event = { id = HF.20305 days = 11 } #Ceremony actually starts
			any_vassal = {
				limit =  {
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = HF.20301 } #Send Invitations
			}
			any_independent_ruler = {
				limit = { 
					war = no
					prisoner = no
					is_theocracy = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
					religion = ROOT 	
					is_within_diplo_range = ROOT
					higher_real_tier_than = DUKE
					NOT = { distance_from_realm = { who = ROOT value = 120 } }
				}
				character_event = { id = HF.20302 } #Send Invitations to other Catholic neighbors
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 1 } 
			} 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.5 } 
			} 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 0
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 3
				tier = EMPEROR
			} 
			modifier = { 
				factor = 0.75
				trait = greedy
			} 
		}
	}
	option = {
		name = EVTOPTBHF20300
		trigger = { war = no }
		set_character_flag = flag_regular_coronation
		custom_tooltip = { text = send_coronation_invitations }
		hidden_tooltip = {
			character_event = { id = HF.20305 days = 11 } #Ceremony actually starts
			any_vassal = {
				limit =  {
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = HF.20301 } #Send Invitations
			}
		}
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -0.5 min = -100 max = -500 }
		}
		ai_chance = { 
			factor = 40 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.5 } 
			} 
			modifier = { 
				factor = 0.5
				NOT = { scaled_wealth = 0.25 } 
			} 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 0
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 0.5
				tier = EMPEROR
			} 
			modifier = { 
				factor = 0.75
				trait = greedy
			} 
		}
	}
	option = {
		name = {
			text = EVTOPTCHF20300
			trigger = {
				war = no
			}
		}
		name = {
			text = EVTOPTCHF20300_B
			trigger = {
				war = yes
			}
		}
		set_character_flag = flag_secluded_coronation
		custom_tooltip = { text = send_seclcoronation_invitations }
		if = { 
			limit = { ai = no } #Cheaty AI...
			scaled_wealth = { value = -0.05 min = -10 max = -150 }
		}
		hidden_tooltip = {
			character_event = { id = HF.20305 days = 11 } #Ceremony actually starts
			any_courtier = {
				limit = { 
					is_councillor = yes 
					prisoner = no
					NOT = { has_character_flag = do_not_disturb }
					NOT = { has_character_modifier = holding_large_feast }
					is_adult = yes
					NOT = { trait = incapable }
					NOT = { is_inaccessible_trigger = yes }
					NOT = { has_any_opinion_modifier = opinion_coronation_guest }
				}
				character_event = { id = HF.20301 } #Send Invitations
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = { 
				factor = 0.25
				NOT = { wealth = 0 } 
			} 
			modifier = { 
				factor = 3
				NOT = { wealth = -100 } 
			} 
			modifier = { 
				factor = 0.1
				tier = EMPEROR
			} 
			modifier = { 
				factor = 1.5
				trait = greedy
			}
		}
	}
}

#Vassal: King is inviting you to his coronation.
letter_event = {
	id = HF.20301
	desc = EVTDESCHFA20301
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes
	trigger = {
		FROM = {
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
		}
	}
	
	option = {
		name = EVTOPTAHF20301
		hidden_tooltip = { FROM = { character_event = { id = HF.20303 days = 3 random = 5 } } } #Notification.
		opinion = {
			modifier = opinion_coronation_guest
			months = 4
			who = FROM
		}
		add_character_modifier = {
			name = out_traveling #Vassal travel is short, so no regent needed.
			duration = 45
		}
		ai_chance = { 
			factor = 70 
		}
	}
	option = {	#End of the line
		name = EVTOPTBHF20301
		hidden_tooltip = { FROM = { character_event = { id = HF.20304 days = 3 random = 5 } } } #Notification.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = {		#Of course he will be present.
				factor = 0
				event_target:coronation_priest = { character = ROOT }
			} 
			modifier = {
				factor = 0.3
				opinion = { who = from value = 100 }
			}
			modifier = {
				factor = 0.4
				opinion = { who = from value = 80 }
			}
			modifier = {
				factor = 0.5
				opinion = { who = from value = 60 }
			}
			modifier = {
				factor = 0.65
				opinion = { who = from value = 40 }
			}
			modifier = {
				factor = 0.75
				opinion = { who = from value = 20 }
			}
			modifier = {
				factor = 0.85
				opinion = { who = from value = 0 }
			}
			modifier = {
				factor = 1.15
				NOT = { opinion = { who = from value = 0 } }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = from value = -20 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -60 } }
			}
			modifier = {
				factor = 1.75
				NOT = { opinion = { who = from value = -80 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = from value = -100 } }
			}
		}
	}
}
#Foreign King: King is inviting you to his coronation.
letter_event = {
	id = HF.20302
	desc = EVTDESCHFA20302
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes
	trigger = {
		FROM = {
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
		}
	}
	
	
	option = {
		name = EVTOPTAHF20302
		hidden_tooltip = { FROM = { character_event = { id = HF.20303 days = 5 random = 5 } } } #Notification.
		FROM = { 
			prestige = 75	# Prestigious guests bring prestige.
		}
		opinion = {
			modifier = opinion_coronation_guest
			months = 4
			who = FROM
		}
		add_trait = travelling #Foreign King's travel is longer, it needs a regent, as if it were a pilgrimage.
		#add_character_modifier = {
		#	name = out_traveling
		#	duration = 45
		#}
		ai_chance = { 
			factor = 70 
		}
	}
	option = {	#End of the line
		name = EVTOPTBHF20302
		hidden_tooltip = { FROM = { character_event = { id = HF.20304 days = 5 random = 5 } } } #Notification.
		FROM = { 
				show_scope_change = no	
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 
			factor = 30
			modifier = {		#Of course he will be present.
				factor = 0
				event_target:coronation_priest = { character = ROOT }
			} 
			modifier = {
				factor = 0.3
				opinion = { who = from value = 100 }
			}
			modifier = {
				factor = 0.4
				opinion = { who = from value = 80 }
			}
			modifier = {
				factor = 0.5
				opinion = { who = from value = 60 }
			}
			modifier = {
				factor = 0.65
				opinion = { who = from value = 40 }
			}
			modifier = {
				factor = 0.75
				opinion = { who = from value = 20 }
			}
			modifier = {
				factor = 0.85
				opinion = { who = from value = 0 }
			}
			modifier = {
				factor = 1.15
				NOT = { opinion = { who = from value = 0 } }
			}
			modifier = {
				factor = 1.25
				NOT = { opinion = { who = from value = -20 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = from value = -60 } }
			}
			modifier = {
				factor = 1.75
				NOT = { opinion = { who = from value = -80 } }
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = from value = -100 } }
			}
		}
	}
}
#King Notification: Vassal will come to the Coronation Ceremony
letter_event = {
	id = HF.20303
	desc = EVTDESCHF20303

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}
	notification = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20303
	}
}
#King Notification: Vassal will not come to the Coronation Ceremony
letter_event = {
	id = HF.20304
	desc = EVTDESCHF20304

	trigger = {
		OR = {
			religion = catholic
			religion = fraticelli
		}
		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}
	notification = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20304
	}
}

#King: Day 11 from budget, ceremony starts.
character_event = {
	id = HF.20305
	desc = {
		trigger = {
			has_character_flag = flag_extravagant_coronation 
			war = no
		}
		text = EVTDESCHFA20305
	}
	desc = {
		trigger = {
			has_character_flag = flag_regular_coronation
			war = no
		}
		text = EVTDESCHFB20305
	}
	desc = {
		trigger = {
			has_character_flag = flag_secluded_coronation
			war = no
		}
		text = EVTDESCHFC20305
	}

	desc = {
		trigger = {
			war = yes
		}
		text = EVTDESDHFD20305
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_magnificent_castle
	border = GFX_event_normal_frame_religion

	trigger = { 
		OR = {
			religion = catholic
			religion = fraticelli
		}
		OR = {
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20305
			#King befriends foreign ruler
			#King befriends vassal
			#King's new acquaintances improve his diplomacy/stewardship
			#King's new acquaintances improve his intrigue/learning
			#King's diplomacy helps him improve opinion of all guests
			#King's new resolve makes him lose slothful/content.
			#Proud King's trepidation makes him gain ambitious.
			#Child King's flattered and can become haughty or conscientious.
			#The coronation_priest approves of the ceremony.
			#Temperate/Celibate coronation_priest disapproves of the extravagant ceremony.
			#HRE/Francia Emperor gets a talk from the priest about being the heir of Charlemagne (chance for prestige, learning, diligent)
			#The Pope talks to the King about his duties as protector of Christendom (chance to gain zealous, cynical, learning).
			#Child king is taught by foreign ruler about stewardship.
			#Two foreign Kings (guests) become (or are) rivals, coronation_ruler with high diplomacy can help them lose rivalry and become his friends.
			#Cynical vassal (or wicked priest) annoys the coronation_priest. High diplomacy ruler may help and gain gregarious.
			#A knight comes to pledge his service to the new King/Emperor, if ruler is female/child, chance to become friend/lover or increase martial.
			#A wise priest joins the court.
			#King becomes rival of one of his vassals.

			#King is embarassed of secluded coronation, chance to gain stressed or paranoid.
			#King's vassals are offended by secluded coronation (chance to avoid with high diplomacy).
			#Coronation_priest is disappointed by secluded ceremony.
			#King is disraught by secluded ceremony (chance to lose ambitious, gain content/slothful).
			#King reflects upon secluded coronation (chance to lose proud, gain humble).
			#King's Councillor becomes his rival due to secluded coronation.
			hidden_tooltip = { set_variable = { which = coronation_count value = 0 } } 
			hidden_tooltip = { character_event = { id = HF.20365 days = 3 random = 3 } } # First and second row of random list.
		hidden_tooltip = { character_event = { id = HF.20366 days = 32 } } #THE CORONATION ITSELF # For safety reasons, just in case guests die in the middle of the feast and prevent the last event from firing.
		
	}
}

#King has chance to befriend foreign ruler.
character_event = {
	id = HF.20306
	desc = EVTDESCHFA20306
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_foreign_friendship } #to avoid the same event happening twice during the coronation.

		random_independent_ruler = { 
			limit = { 
				has_opinion_modifier = { 
					who = ROOT 
					modifier = opinion_coronation_guest 
				}
				NOT = { is_rival = ROOT } 
				NOT = { is_friend = ROOT } 
				NOT = { is_lover = ROOT } 
				NOT = { is_married = ROOT }
				NOT = { num_of_friends = 3 }
				opinion = { who = from value = -20 }
			} 
			save_event_target_as = potential_friend
		}
	}
	
	option = {
		name = EVTOPTAHF20306
		show_portrait = event_target:potential_friend
		event_target:potential_friend = { 
			character_event = { id = HF.20307 tooltip = EVTTOOLTIPAHF20307 }
		}
		ai_chance = { 	
			factor = 90
			modifier = { 
				factor = 0.5
				trait = shy
			}	
			modifier = { 
				factor = 0.5
				trait = paranoid
			}	
		}
	}
	option = {
		name = EVTOPTBHF20306
		ai_chance = { 	
			factor = 10	
		}
	}

	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Foreign ruler/Vassal: King wants to become your friend.
character_event = {
	id = HF.20307
	desc = EVTDESCHFA20307
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20307
		add_friend = FROM
		hidden_tooltip = { FROM = { character_event = { id = HF.20308 } } }
		ai_chance = { 	
			factor = 90
			modifier = { 
				factor = 0.8
				FROM = { trait = shy }
			}	
			modifier = { 
				factor = 0.75
				FROM = { trait = cruel }
				NOT = { trait = cruel }
			}	
			modifier = { 
				factor = 0.5
				trait = envious
			}
		}
	}
	option = {
		name = EVTOPTBHF20307
		FROM = { character_event = { id = HF.20309 tooltip = EVTTOOLTIPAHF20309 } }
		ai_chance = { 	
			factor = 10	
		}
	}
}

#King: you've acquired a new friend.
character_event = {
	id = HF.20308
	desc = EVTDESCHFA20308
	desc = {
		trigger = {
			FROM = { NOT = { vassal_of = ROOT } }
		}
		text = EVTDESCHFA20308
	}
	desc = {
		trigger = {
			FROM = { vassal_of = ROOT }
		}
		text = EVTDESCHFB20308
	}
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20308
		add_friend = FROM
		ai_chance = { 	
			factor = 100
		}
	}
}

#King: you have not acquired a new friend.
character_event = {
	id = HF.20309
	desc = EVTDESCHFA20309
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20309
		ai_chance = { 	
			factor = 100
		}
	}
}

#King has chance to befriend one of his vassals.
character_event = {
	id = HF.20310
	desc = EVTDESCHFA20310
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_vassal_friendship } #to avoid the same event happening twice during the coronation.
		random_vassal = { 
			limit = { 
				has_opinion_modifier = { 
					who = ROOT 
					modifier = opinion_coronation_guest 
				}
				NOT = { is_rival = ROOT } 
				NOT = { is_friend = ROOT } 
				NOT = { is_lover = ROOT } 
				NOT = { is_married = ROOT }
				NOT = { num_of_friends = 3 }
				opinion = { who = from value = -20 }
			} 
			save_event_target_as = potential_friend
		}
	}
	
	option = {
		name = EVTOPTAHF20310
		show_portrait = event_target:potential_friend
		event_target:potential_friend = {  
			character_event = { id = HF.20307 tooltip = EVTTOOLTIPAHF20307 }
		}
		ai_chance = { 	
			factor = 90
			modifier = { 
				factor = 0.5
				trait = shy
			}	
			modifier = { 
				factor = 0.5
				trait = paranoid
			}	
		}
	}
	option = {
		name = EVTOPTBHF20310
		ai_chance = { 	
			factor = 10	
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#King talks with guests, chance to gain diplomacy or stewardship.
character_event = {
	id = HF.20311
	desc = EVTDESCHFA20311
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_diplomacy_boost } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20311
		change_diplomacy = 1
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20312 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20312 }
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = { 
				factor = 0.5
				NOT = { diplomacy = 10 }
			}		
		}
	}
	option = {
		name = EVTOPTBHF20311
		change_stewardship = 1
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20313 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20313 }
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = { 
				factor = 0.5
				NOT = { stewardship = 10 }
			}		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}


#Coronation guest: ruler displays diplomacy.
character_event = {
	id = HF.20312
	desc = EVTDESCHFA20312
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20312
		prestige = 40
		random = { 
			chance = 5
			change_diplomacy = 1
		}
		ai_chance = { 	
			factor = 100
		}
	}
}
#Coronation guest: ruler displays stewardship.
character_event = {
	id = HF.20313
	desc = EVTDESCHFA20313
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20313
		prestige = 40
		random = { 
			chance = 5
			change_stewardship = 1
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#King talks with guests, chance to gain intrigue or learning.
character_event = {
	id = HF.20314
	desc = EVTDESCHFA20314
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_learning_boost  } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20314
		change_intrigue = 1
		ai_chance = { 	
			factor = 50
			modifier = { 
				factor = 0.5
				NOT = { intrigue = 10 }
			}		
		}
	}
	option = {
		name = EVTOPTBHF20314
		change_learning = 1
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20315 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20315 }
			}
		}
		ai_chance = { 	
			factor = 50	
			modifier = { 
				factor = 0.5
				NOT = { learning = 10 }
			}		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Coronation guest: ruler displays learning.
character_event = {
	id = HF.20315
	desc = EVTDESCHFA20315
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20315
		piety = 50
		random = { 
			chance = 5
			change_learning = 1
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#King shows off with guests, chance to improve opinion.
character_event = {
	id = HF.20316
	desc = {
		trigger = {
			age = 16
		}
		text = EVTDESCHFA20316
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFB20316
	}
	hide_new = yes 


	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_guest_opinions } #to avoid the same event happening twice during the coronation.
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20316
		custom_tooltip = { text = EVTTOOLTIPAHF20316 }
		hidden_tooltip = {
			random_list = {
				50 = {
					modifier = { 
						factor = 1.5
						has_character_flag = flag_extravagant_coronation
					}
					modifier = { 
						factor = 1.25
						diplomacy = 6
					}
					modifier = { 
						factor = 1.25
						diplomacy = 8
					}
					modifier = { 
						factor = 1.25
						diplomacy = 10
					}
					modifier = { 
						factor = 1.5
						diplomacy = 12
					}
					modifier = { 
						factor = 1.75
						diplomacy = 15
					}	
					modifier = { 
						factor = 1.25
						trait = gregarious
					}
					modifier = { 
						factor = 0.5
						trait = shy
					}
					modifier = { 
						factor = 1.25
						trait = underhanded_rogue
					}
					modifier = { 
						factor = 1.5
						trait = charismatic_negotiator
					}
					modifier = { 
						factor = 1.75
						trait = grey_eminence
					}
					modifier = { 
						factor = 1.75
						NOT = { age = 16 } #Lower expectations
					}
					character_event = { id = HF.20317 } #Success
				}
				50 = {
					character_event = { id = HF.20318 } #Failure
				
				}
			}

		}
		ai_chance = { 	
			factor = 90
			modifier = { 
				factor = 0.75
				NOT = { diplomacy = 10 }
			}	
			modifier = { 
				factor = 0.5
				trait = shy
			}		
		}
	}
	option = {
		name = EVTOPTBHF20316
		ai_chance = { 	
			factor = 10			
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}


#Success: King has impressed his guests
character_event = {
	id = HF.20317
	desc = {
		trigger = {
			age = 16
		}
		text = EVTDESCHFA20317
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFB20317
	}
	hide_new = yes 

	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20317
		custom_tooltip = { text = EVTTOOLTIPAHF20317 }
		if = { 
			limit = { age = 16 } 
			prestige = 75
		}
		if = { 
			limit = { NOT = { age = 16 } } 
			prestige = 150
		}
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20319 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20319 }
			}
			event_target:coronation_priest = {  
				character_event = { id = HF.20319 }
			}
		}		
		ai_chance = { 	
			factor = 100
		}
	}
}

#Failure: King has not impressed his guests
character_event = {
	id = HF.20318
	desc = {
		trigger = {
			age = 16
		}
		text = EVTDESCHFA20318
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFB20318
	}
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20318
		custom_tooltip = { text = EVTTOOLTIPAHF20318 }
		if = { 
			limit = { age = 16 } 
			prestige = -90
		}
		if = { 
			limit = { NOT = { age = 16 } } 
			prestige = -40
		}
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20320 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20320 }
			}
			event_target:coronation_priest = {  
				character_event = { id = HF.20320 }
			}
		}		
		ai_chance = { 	
			factor = 100
		}
	}
}


#Coronation guest: ruler speech increased opinion.
character_event = {
	id = HF.20319
	desc = {
		trigger = {
			age = 16
		}
		text = EVTDESCHFA20319
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFB20319
	}
	hide_new = yes 

	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20319
		prestige = 40
		opinion = {
			modifier = opinion_swayed_1
			years = 10
			who = FROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Coronation guest: ruler speech did not increase opinion.
character_event = {
	id = HF.20320
	desc = {
		trigger = {
			age = 16
		}
		text = EVTDESCHFA20320
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFB20320
	}
	hide_new = yes 


	picture = GFX_evt_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20320
		opinion = {
			modifier = opinion_tiresome
			years = 3
			who = FROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#King galvanized by upcoming coronation, chance to lose content or slothful.
character_event = {
	id = HF.20321
	desc = EVTDESCHFA20321
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_gain_diligent } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20321
		trigger = { trait = content }
		prestige = 75
		random = { 
			chance = 50
			remove_trait = content 
			hidden_tooltip = { character_event = { id = 38299 } } 
		}
		ai_chance = { 	
			factor = 50	
		}
	}
	option = {
		name = EVTOPTBHF20321
		trigger = { trait = slothful }
		piety = 20
		random = { 
			chance = 50
			remove_trait = slothful 
			hidden_tooltip = { character_event = { id = 38298 } } 
		}
		ai_chance = { 	
			factor = 50		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Proud King galvanized by upcoming coronation, chance to become ambitious or lose proud.
character_event = {
	id = HF.20322
	desc = EVTDESCHFA20322
	hide_new = yes 

	picture = GFX_evt_fancy_feast
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_gain_ambitious  } #to avoid the same event happening twice during the coronation.
	}
	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20322
		prestige = 75
		if = { limit = { NOT = { trait = ambitious } }
			random = { 
				chance = 50
				add_trait = ambitious
				hidden_tooltip = { character_event = { id = 38278 } } 
			}
		}
		if = { limit = { trait = ambitious }
			random = { 
				chance = 50
				prestige = 75
			}
		}
		ai_chance = { 	
			factor = 50	
		}
	}
	option = {
		name = EVTOPTBHF20322
		piety = 50
		random = { 
			chance = 50
			remove_trait = proud 
			hidden_tooltip = { character_event = { id = 38300 } } 
		}
		ai_chance = { 	
			factor = 50		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Child King galvanized by upcoming coronation, chance to become haughty or conscientious.
character_event = {
	id = HF.20323
	desc = EVTDESCHFA20323
	hide_new = yes 

	picture = GFX_evt_child_reading
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_haughty_child } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20323
		if = { 
			limit = { NOT = { trait = haughty } has_dlc = "Conclave" }
			prestige = 75
			random = { 
				chance = 50
				add_trait = haughty 
			}
			break = yes
		}
		if = { 
			limit = { OR = { NOT = { has_dlc = "Conclave" } trait = haughty } }
			prestige = 75
		}
		ai_chance = { 	
			factor = 50	
		}
	}
	option = {
		name = EVTOPTBHF20323
		if = { 
			limit = { NOT = { trait = conscientious } has_dlc = "Conclave" }
			piety = 50
			random = { 
				chance = 50
				add_trait = conscientious 
			}
			break = yes
		}
		if = { 
			limit = { OR = { NOT = { has_dlc = "Conclave" } trait = conscientious } }
			piety = 75
		}
		ai_chance = { 	
			factor = 50		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#King: coronation_priest is pleased by the feast.
character_event = {
	id = HF.20324
	desc = EVTDESCHFA20324
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_priest_approves } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20324
		if = { 
			limit = { age = 16 } 
			piety = 40
		}
		if = { 
			limit = { NOT = { age = 16 } } 
			piety = 60
		}
		event_target:coronation_priest = {	
				show_scope_change = no	
			opinion = {
				modifier = opinion_impressed
				years = 10
				who = ROOT
			}
		}
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20325 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20325 }
			}
		}		
		ai_chance = { 	
			factor = 100
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Coronation guest: coronation_priest is impressed by the feast.
character_event = {
	id = HF.20325
	desc = EVTDESCHFA20325
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20325
		piety = 50
		ai_chance = { 	
			factor = 100
		}
	}
}

#Emperor of Francia/HRE: coronation_priest speaks about responsibility of Charlemagne.
character_event = {
	id = HF.20326
	desc = EVTDESCHFA20326
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_hre_talk } #to avoid the same event happening twice during the coronation.
	}


	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20326
		prestige = 100
		ai_chance = { 	
			factor = 40
		}
	}
	option = {
		name = EVTOPTBHF20326
		change_learning = 2
		ai_chance = { 	
			factor = 30
		}
	}
	option = {
		name = EVTOPTCHF20326
		if = { 
			limit = {
				trait = slothful
			} 
			remove_trait = slothful
			hidden_tooltip = { character_event = { id = 38298 } } 
			break = yes
		}
		if = { 
			limit = { trait = diligent } 
			piety = 30
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = diligent } 
			} 
			add_trait = diligent
			hidden_tooltip = { character_event = { id = 38256 } } 
		}

		ai_chance = { 	
			factor = 30
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#King: Pope talks about responsibility of Catholic Kings.
character_event = {
	id = HF.20327
	desc = EVTDESCHFA20327
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_pope_talk  } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20327
		if = { 
			limit = {
				trait = cynical
			} 
			remove_trait = cynical
			hidden_tooltip = { character_event = { id = 38316 } } 
			break = yes
		}
		if = { 
			limit = { trait = zealous } 
			piety = 75
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = zealous } 
			} 
			add_trait = zealous
			hidden_tooltip = { character_event = { id = 38269 } } 
		}
		ai_chance = { 	
			factor = 50
		}
	}
	option = {
		name = EVTOPTBHF20327
		change_learning = 2
		ai_chance = { 	
			factor = 50
		}
	}
	option = {
		name = EVTOPTCHF20327
		if = { 
			limit = {
				trait = zealous
			} 
			remove_trait = zealous
			hidden_tooltip = { character_event = { id = 38310 } } 
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = cynical } 
			} 
			add_trait = cynical
			hidden_tooltip = { character_event = { id = 38258 } } 
		}

		ai_chance = { 	
			factor = 0
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Foreign coronation guest: chance to teach Child King about stewardship.
character_event = {
	id = HF.20328
	desc = EVTDESCHFA20328
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_foreign_teacher } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20328
			event_target:coronation_ruler = { character_event = { id = HF.20329 tooltip = EVTTOOLTIPHF20329 } }
		if = { 
			limit = {
				trait = slothful
			} 
			remove_trait = slothful
			hidden_tooltip = { character_event = { id = 38298 } } 
			break = yes
		}
		if = { 
			limit = { trait = diligent } 
			piety = 20
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = diligent } 
			} 
			add_trait = diligent
			hidden_tooltip = { character_event = { id = 38256 } } 
		}
		ai_chance = { 	
			factor = 99
			modifier = { 
				factor = 0.5
				trait = slothful
			} 
		}
	}
	option = {
		name = EVTOPTBHF20328
		prestige = 75
		if = { 
			limit = { 
				trait = humble 
			} 
			random = { 
				chance = 50 
				remove_trait = humble
				hidden_tooltip = { character_event = { id = 38312 } } 
			} 
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = proud } 
			} 
			random = { 
				chance = 50 
				add_trait = proud
				hidden_tooltip = { character_event = { id = 38261 } } 
			} 
		}
		ai_chance = { 	
			factor = 1
		}
	}
}
#Child King: foreign ruler wants to teach you about statemanship.
character_event = {
	id = HF.20329
	desc = EVTDESCHFA20329
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20329
		FROM = { character_event = { id = HF.20330 tooltip = EVTTOOLTIPHF20330 } }
		change_stewardship = 2
		FROM = {
				show_scope_change = no	
			opinion = {
				modifier = opinion_impressed
				years = 10
				who = ROOT
			}
		}
		ai_chance = { 	
			factor = 80
			modifier = { 
				factor = 0.5
				trait = slothful
			} 
			modifier = { 
				factor = 0.5
				trait = indolent
			} 
			modifier = { 
				factor = 0.5
				trait = haughty
			} 
			modifier = { 
				factor = 1.75
				trait = conscientious
			} 
		}
	}
	option = {
		name = EVTOPTBHF20329
		FROM = { character_event = { id = HF.20331 tooltip = EVTTOOLTIPHF20331 } }
		FROM = {
				show_scope_change = no	
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = ROOT
			}
		}
		if = { 
			limit = { 
				trait = conscientious 
			} 
			random = { 
				chance = 50 
				remove_trait = conscientious
			} 
			break = yes
		}
		if = { 
			limit = { 
				NOT = { trait = indolent } 
			} 
			random = { 
				chance = 50 
				add_trait = indolent
			} 
		}
		ai_chance = { 	
			factor = 20
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Foreign Coronation guest: Child King appreciated your help.
character_event = {
	id = HF.20330
	desc = EVTDESCHFA20330
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20330
		tooltip = {
			opinion = {
				modifier = opinion_impressed
				years = 10
				who = FROM
			}
		}
		ai_chance = { 	
			factor = 100 
		}
	}
}

#Foreign Coronation guest: Child King did not appreciate your help.
character_event = {
	id = HF.20331
	desc = EVTDESCHFA20331
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20331
		tooltip = {
			opinion = {
				modifier = opinion_dislike
				years = 10
				who = FROM
			}
		}
		ai_chance = { 	
			factor = 100 
		}
	}
}

#King: coronation_priest is displeased by the feast.
character_event = {
	id = HF.20332
	desc = EVTDESCHFA20332
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_priest_disapproves } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20332
		if = { 
			limit = { age = 16 } 
			piety = -75
		}
		if = { 
			limit = { NOT = { age = 16 } } 
			piety = -25
		}
		event_target:coronation_priest = {	
				show_scope_change = no	
			opinion = {
				modifier = opinion_disapprove
				years = 10
				who = ROOT
			}
		}
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20333 }
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20333 }
			}
		}		
		ai_chance = { 	
			factor = 100
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Coronation guest: coronation_priest is displeased by the feast.
character_event = {
	id = HF.20333
	desc = EVTDESCHFA20333
	hide_new = yes 

	picture = GFX_evt_church_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20333
		ai_chance = { 	
			factor = 100
		}
	}
}

#Foreign Coronation guest: you become (or are) rival with another guest. (hidden)
character_event = {
	id = HF.20334
	hide_window = yes

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	immediate = {
		event_target:coronation_ruler = { set_character_flag = flag_coronation_diplomatic_incident } #to avoid the same event happening twice during the coronation.
		random_list = { 	
			50 = { #First check if you already have a foreign ruler guest as a rival
				modifier = { 
					factor = 0
					NOT = { 
						any_independent_ruler = { 
							has_opinion_modifier = { 
								who = event_target:coronation_ruler
								modifier = opinion_coronation_guest 
							}
							is_rival = ROOT
						}
					}
				}
				set_character_flag = flag_met_old_rival
				random_independent_ruler = { 
					limit = { 
						has_opinion_modifier = { 
							who = event_target:coronation_ruler
							modifier = opinion_coronation_guest 
						}
						is_rival = ROOT
					} 
					character_event = { id = HF.20335 } 
				}
			}
			50 = { #Otherwise create a new rivalry
				modifier = { 
					factor = 0
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = event_target:coronation_ruler
							modifier = opinion_coronation_guest 
						}
						NOT = {
							opinion = { 
								who = ROOT
								value = -30 
							}
						}
					}
				}
				random_independent_ruler = { 
					limit = { 
						has_opinion_modifier = { 
							who = event_target:coronation_ruler
							modifier = opinion_coronation_guest 
						}
						NOT = {
							opinion = { 
								who = ROOT
								value = -30 
							}
						} 
					} 
					character_event = { id = HF.20335 } 
				}
			}
		}
	}
}

#Coronation guest 2: new or old rivalry disrupts the feast.
character_event = {
	id = HF.20335
	desc = {
		trigger = {
			FROM = { has_character_flag = flag_met_old_rival }
		}
		text = EVTDESCHFA20335
	}
	desc = {
		trigger = {
			NOT = { FROM = { has_character_flag = flag_met_old_rival } }
		}
		text = EVTDESCHFB20335
	}
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20335
		if = { 
			limit = { 
				NOT = { is_rival = FROM } 
			}
			add_rival = FROM
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20336 } } }
		hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20337 } } }
		ai_chance = { 	
			factor = 100
		}
	}
}

#Coronation guest 1: new or old rivalry disrupts the feast.
character_event = {
	id = HF.20336
	desc = {
		trigger = {
			has_character_flag = flag_met_old_rival
		}
		text = EVTDESCHFA20336
	}
	desc = {
		trigger = {
			NOT = { has_character_flag = flag_met_old_rival }
		}
		text = EVTDESCHFB20336
	}
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20336
		if = { 
			limit = { 
				NOT = { is_rival = FROM } 
			}
			add_rival = FROM
		}
		clr_character_flag = flag_met_old_rival
		ai_chance = { 	
			factor = 100
		}
	}
}

#King: two foreign rulers are bickering, do you interfere?
character_event = {
	id = HF.20337
	desc = EVTDESCHFA20337
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20337
		tooltip_info = diplomacy
		custom_tooltip = { text = EVTTOOLTIPAHF20337 }
		hidden_tooltip = { 
			random_list = { 
				#Critical Success
				#Success
				#Failure
				#Critical Failure
				10 = { 

				modifier = { 
					factor = 0
					num_of_friends = 3
				} 
				modifier = { 
					factor = 0.1
					NOR = { 
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
						trait = grey_eminence
						diplomacy = 15
					}
				} 
				modifier = { 
					factor = 0.5
					OR = { 
						FROM = { trait = stubborn }
						FROMFROM = { trait = stubborn }
					}
				} 
				ROOT = { character_event = { id = HF.20338 } } # King succeeds and becomes friends with the rulers.
				FROM = { character_event = { id = HF.20338 } }
				FROMFROM = { character_event = { id = HF.20338 } }
				} 
				40 = { 

				modifier = { 
					factor = 0.8
					NOR = { 
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
						trait = grey_eminence
					}
				} 
				modifier = { 
					factor = 0.5
					OR = { 
						FROM = { trait = stubborn }
						FROMFROM = { trait = stubborn }
					}
				}
				modifier = { 
					factor = 0.25
					NOT = { diplomacy = 1 }
				}
				modifier = { 
					factor = 0.5
					NOT = { diplomacy = 2 }
				}
				modifier = { 
					factor = 0.75
					NOT = { diplomacy = 4 }
				}
				modifier = { 
					factor = 0.75
					NOT = { diplomacy = 6 }
				}
				modifier = { 
					factor = 0.75
					NOT = { diplomacy = 8 }
				}
				ROOT = { character_event = { id = HF.20339 } } # King succeeds, ending the rivalry.
				FROM = { character_event = { id = HF.20339 } }
				FROMFROM = { character_event = { id = HF.20339 } }
				} 
				40 = { 

				modifier = { 
					factor = 0.75
					diplomacy = 8
				}
				modifier = { 
					factor = 0.75
					diplomacy = 10
				}
				modifier = { 
					factor = 0.75
					diplomacy = 12
				}
				modifier = { 
					factor = 0.75
					diplomacy = 14
				}
				modifier = { 
					factor = 0.5
					diplomacy = 16
				}
				modifier = { 
					factor = 0.5
					diplomacy = 18
				}
				modifier = { 
					factor = 0.25
					diplomacy = 20
				}
				modifier = { 
					factor = 0.5
					trait = charismatic_negotiator
				}
				modifier = { 
					factor = 0.25
					trait = grey_eminence
				}
				modifier = { 
					factor = 0.75
					trait = gregarious
				}
				modifier = { 
					factor = 0.75
					trait = honest
				}
				ROOT = { character_event = { id = HF.20340 } } # King fails.
				FROM = { character_event = { id = HF.20340 } }
				FROMFROM = { character_event = { id = HF.20340 } }
				} 
				10 = { 
				modifier = { 
					factor = 0.1
					OR = { 
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
						trait = grey_eminence
						diplomacy = 15
					}
				}

				modifier = { 
					factor = 0
					num_of_rivals = 3
				}
				ROOT = { character_event = { id = HF.20341 } } # King fails and becomes rival with rulers.
				FROM = { character_event = { id = HF.20341 } }
				FROMFROM = { character_event = { id = HF.20341 } }
				} 
			} 
		}
		ai_chance = { 	
			factor = 75
			modifier = { 
				factor = 0.5
				NOT = { diplomacy = 10 }
			} 
			modifier = { 
				factor = 0.5
				trait = shy
			} 
		}
	}
	option = {
		name = EVTOPTBHF20337
		prestige = -50
		piety = -25
		ai_chance = { 	
			factor = 25
			modifier = { 
				factor = 0.5
				trait = gregarious
			}
			modifier = { 
				factor = 0.5
				trait = proud
			}
			modifier = { 
				factor = 1.75
				trait = shy
			}
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Foreign incident: Critical success.
character_event = {
	id = HF.20338
	desc = {
		trigger = {
			ROOT = { character = FROM } #desc for host King
		}
		text = EVTDESCHFA20338
	}
	desc = {
		trigger = {
			NOT = { ROOT = { character = FROM } } #desc for two rivals
		}
		text = EVTDESCHFB20338
	}
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20338
		if = { 
			limit = { 
				ROOT = { character = FROMFROM } 
			}
			remove_rival = FROMFROMFROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROMFROMFROM } 
			}
			remove_rival = FROMFROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROM } 
			}
			add_friend = FROMFROM
			add_friend = FROMFROMFROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Foreign incident: success.
character_event = {
	id = HF.20339
	desc = {
		trigger = {
			ROOT = { character = FROM } #desc for host King
		}
		text = EVTDESCHFA20339
	}
	desc = {
		trigger = {
			NOT = { ROOT = { character = FROM } } #desc for two rivals
		}
		text = EVTDESCHFB20339
	}
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20339
		if = { 
			limit = { 
				ROOT = { character = FROMFROM } 
			}
			remove_rival = FROMFROMFROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROMFROMFROM } 
			}
			remove_rival = FROMFROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROM } 
			}
			prestige = 100
		}
		ai_chance = { 	
			factor = 100
		}
	}
}
#Foreign incident: failure.
character_event = {
	id = HF.20340
	desc = {
		trigger = {
			ROOT = { character = FROM } #desc for host King
		}
		text = EVTDESCHFA20340
	}
	desc = {
		trigger = {
			NOT = { ROOT = { character = FROM } } #desc for two rivals
		}
		text = EVTDESCHFB20340
	}
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20340
		if = { 
			limit = { 
				ROOT = { character = FROMFROM } 
			}
			opinion = {
				who = FROM
				modifier = opinion_angry
				months = 30
			}
		}
		if = { 
			limit = { 
				ROOT = { character = FROMFROMFROM } 
			}		
			opinion = {
				who = FROM
				modifier = opinion_angry
				months = 30
			}
		}
		if = { 
			limit = { 
				ROOT = { character = FROM } 
			}
			prestige = -100
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Foreign incident: critical failure, gained new rivals.
character_event = {
	id = HF.20341
	desc = {
		trigger = {
			ROOT = { character = FROM } #desc for host King
		}
		text = EVTDESCHFA20341
	}
	desc = {
		trigger = {
			NOT = { ROOT = { character = FROM } } #desc for two rivals
		}
		text = EVTDESCHFB20341
	}
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20341
		if = { 
			limit = { 
				ROOT = { character = FROMFROM } 
			}
			add_rival = FROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROMFROMFROM } 
			}		
			add_rival = FROM
		}
		if = { 
			limit = { 
				ROOT = { character = FROM } 
			}
			prestige = -100
			add_rival = FROMFROM
			add_rival = FROMFROMFROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Cynical/Wicked guest annoys coronation_priest.
character_event = {
	id = HF.20342
	desc = EVTDESCHFA20342
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20342
		event_target:coronation_priest = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_insulted
				months = 30
			}
		}
		hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20364 } } }
		ai_chance = { 	 
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20342
		ai_chance = { 	
			factor = 0
		}
	}
}

#King notified that coronation_priest has been offended, decide what to do.
character_event = {
	id = HF.20364
	desc = EVTDESCHFA20364
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_cynic_taunts } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = { #Use high diplomacy to make both happy
		name = EVTOPTAHF20364
		tooltip_info = diplomacy
		trigger = { diplomacy = 10 }
		prestige = 75
		piety = 25
		 event_target:coronation_priest = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_feast_friend
				months = 30
			}
		}
		FROM = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_feast_friend
				months = 30
			}
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20343 } } }
		ai_chance = { 	 
			factor = 100
		}
	}
	option = { #Support coronation_priest
		name = EVTOPTBHF20364
		piety = 75
		hidden_tooltip = { FROM = { character_event = { id = HF.20344 } } }
		 event_target:coronation_priest = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_feast_friend
				months = 30
			}
		}
		FROM = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_insulted
				months = 30
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = { 
				factor = 0.5
				trait = cynical
			} 
		}
	}
	option = { #Support guest
		name = EVTOPTCHF20364
		prestige = 75
		hidden_tooltip = { FROM = { character_event = { id = HF.20345 } } }
		 event_target:coronation_priest = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_insulted
				months = 30
			}
		}
		 FROM = {
				show_scope_change = no	
			opinion = {
				who = ROOT
				modifier = opinion_feast_friend
				months = 30
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = { 
				factor = 0.5
				trait = zealous
			} 
		}
	}
	option = { #Support neither
		name = EVTOPTDHF20364
		ai_chance = { 	
			factor = 1
			modifier = { 
				factor = 10
				trait = shy
			} 
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Cynical/Wicked learns lesson.
character_event = {
	id = HF.20343
	desc = EVTDESCHFA20343
	hide_new = yes 

	picture = GFX_evt_state_diplomacy
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20343
		tooltip = {
			opinion = {
				who = FROM
				modifier = opinion_feast_friend
				months = 30
			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
}
#Cynical/Wicked insulted.
character_event = {
	id = HF.20344
	desc = EVTDESCHFA20344
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20344
		tooltip = {
			opinion = {
				who = FROM
				modifier = opinion_insulted
				months = 30
			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
}
#Cynical/Wicked glad of support.
character_event = {
	id = HF.20345
	desc = EVTDESCHFA20345
	hide_new = yes 

	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20345
		tooltip = {
			opinion = {
				who = FROM
				modifier = opinion_feast_friend
				months = 30
			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
}

#King: A valiant knight has come to offer his services.
character_event = {
	id = HF.20346
	desc = {
		trigger = {
			NOT = { is_female = yes }
			age = 16
		}
		text = EVTDESCHFA20346
	}
	desc = {
		trigger = {
			is_female = yes
			age = 16
		}
		text = EVTDESCHFB20346
	}
	desc = {
		trigger = {
			NOT = { age = 16 }
		}
		text = EVTDESCHFC20346
	}

	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = {
		event_target:coronation_ruler = { set_character_flag = flag_coronation_wandering_knight } #to avoid the same event happening twice during the coronation.

		create_random_soldier = {
			random_traits = yes
			dynasty = none
			culture = ROOT
			religion = ROOT
			female = no
			age = 24
			attributes = {
				learning = 10
				martial = 15
				}
			}
		new_character = {
			save_event_target_as = coronation_knight
			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull
			
			remove_trait = mystic
			remove_trait = socializer
			remove_trait = gamer
			remove_trait = hedonist
			remove_trait = strategist
			remove_trait = administrator
			remove_trait = architect
			remove_trait = gardener
			remove_trait = schemer
			remove_trait = impaler
			remove_trait = seducer
			remove_trait = seductress
			remove_trait = theologian
			remove_trait = scholar
			remove_trait = craven
			add_trait = brave
			random = { 
				chance = 10
				add_trait = zealous
			}
			random = { 
				chance = 30 
				add_trait = charitable
			}
			random = { 
				chance = 30 
				add_trait = kind
			}
			random = { 
				chance = 40 
				add_trait = celibate
			}
			if = { 
				limit = { year = 1100 }
				random = { 
					chance = 30 
					add_trait = crusader
				}
			}
		}
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20346
		show_portrait = coronation_knight
		event_target:coronation_knight = { 
			move_character = ROOT 
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
		hidden_tooltip = { 
			random_list = { 
				30 = {  } 
				40 = { #Court Love
					trigger = { 
						is_female = yes
						is_adult = yes
						NOT = { num_of_lovers = 3 }
					} 
					modifier = { 
						factor = 1.5
						has_fair_trait_trigger = yes
					} 
					modifier = { 
						factor = 0.5
						has_ugly_trait_trigger = yes
					} 
					modifier = { 
						factor = 0.5
						trait = inbred
					}
					modifier = { 
						factor = 0.75
						trait = harelip
					}
					modifier = { 
						factor = 0.75
						trait = lisp
					}
					modifier = { 
						factor = 0.75
						trait = hunchback
					}
					modifier = { 
						factor = 0.75
						trait = dwarf
					}
					modifier = { 
						factor = 1.5
						trait = gregarious
					} 
					modifier = { 
						factor = 1.5
						trait = quick
					} 
					modifier = { 
						factor = 1.5
						trait = genius
					} 
					modifier = { 
						factor = 1.5
						trait = chaste
					} 
					modifier = { 
						factor = 1.5
						trait = celibate
					} 
					modifier = { 
						factor = 0.5
						age = 40
					} 
					modifier = { 
						factor = 1.75
						is_married = no
					} 
					modifier = { 
						factor = 1.5
						event_target:coronation_knight = { trait = lustful }
					}
					hidden_tooltip = { character_event = { id = HF.20347 days = 2 random = 2 } }
				} 
				40 = { #Squire King

					modifier = { 
						factor = 0
						age = 16
					} 
					modifier = { 
						factor = 1.5
						trait = brave
					} 
					modifier = { 
						factor = 1.5
						trait = strong
					} 
					modifier = { 
						factor = 1.5
						trait = robust
					} 
					modifier = { 
						factor = 1.5
						trait = rowdy
					} 
					modifier = { 
						factor = 0.75
						trait = hunchback
					}
					modifier = { 
						factor = 0.75
						trait = dwarf
					}
					modifier = { 
						factor = 0.5
						trait = inbred
					}
					modifier = { 
						factor = 0.5
						trait = weak
					}
					modifier = { 
						factor = 0.75
						trait = slow
					}
					modifier = { 
						factor = 0.5
						trait = imbecile
					}
					modifier = { 
						factor = 0.75
						trait = feeble
					}
					hidden_tooltip = { character_event = { id = HF.20350 days = 2 random = 2 } }

				 } 
			} 
		}
		ai_chance = { 	 
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20346
		
		hidden_tooltip = {
			event_target:coronation_knight = { 
				death = {
					death_reason = death_missing
				}
			}
		}
		ai_chance = { 	 
			factor = 0
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Queen: travelling knight has fallen in love with you.
character_event = {
	id = HF.20347
	desc = EVTDESCHFA20347

	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20347
		event_target:coronation_knight = { add_lover = ROOT }
		hidden_tooltip = { add_lover = event_target:coronation_knight }
		hidden_tooltip = { #Chance affair is discovered
		random = { chance = 50
				character_event = { id = HF.20348 days = 1 }
				any_vassal = { 
					limit = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
					} 
					character_event = { id = HF.20349 days = 1 }
				}
				any_independent_ruler = { 
					limit = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
					} 
					character_event = { id = HF.20349 days = 1 }
				}
				event_target:coronation_priest = {  
					character_event = { id = HF.20349 days = 1 }
				}
			}
		}
		ai_chance = { 	 
			factor = 80
			modifier = { 
				factor = 0
				trait = homosexual
			}
			modifier = { 
				factor = 0.25
				is_married = yes
			}
			modifier = { 
				factor = 0.25
				num_of_lovers = 1
			}
			modifier = { 
				factor = 0.5
				event_target:coronation_knight = { has_ugly_trait_trigger = yes }
			}
			modifier = { 
				factor = 0.5
				event_target:coronation_knight = { trait = weak }
			}
		}
	}
	option = { #Let's just be friends.
		name = EVTOPTBHF20347
		trigger = { diplomacy = 10 }
		tooltip_info = diplomacy
		event_target:coronation_knight = { add_friend = ROOT }
		hidden_tooltip = { add_friend = event_target:coronation_knight }
		ai_chance = { 	 
			factor = 10
		}
	}
	option = {
		name = EVTOPTCHF20347
		custom_tooltip = { text = EVTTOOLTIPBHF20347 }
		hidden_tooltip = {
			event_target:coronation_knight = { 
				death = {
					death_reason = death_missing
				}
			}
		}
		ai_chance = { 	 
			factor = 10
		}
	}
}

#Queen: your affair with the knight has been discovered.
character_event = {
	id = HF.20348
	desc = EVTDESCHFA20348

	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		event_target:coronation_knight = { is_alive = yes } #Check if the knight is still alive.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20348
		piety = -50
		if = { 
			limit = { 
				is_married = yes
				NOT = { has_character_modifier = adulterer }
			}
			add_character_modifier = {
				name = adulteress
 				days = -1
 			}
 			spouse = {
				show_scope_change = no	
				opinion = {
					who = ROOT
					modifier = opinion_cuckolded
					months = 1200
				}
 			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
}

#Crowning guest: the Queen's affair has been revealed.
character_event = {
	id = HF.20349
	desc = EVTDESCHFA20349
	hide_new = yes 

	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		event_target:coronation_knight = { is_alive = yes } #Check if the knight is still alive.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20349
		ai_chance = { 	 
			factor = 100
		}
	}
}

#Child King: the knight wants to teach you combat.
character_event = {
	id = HF.20350
	desc = EVTDESCHFA20350
	hide_new = yes 

	picture = GFX_evt_child_sword
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		event_target:coronation_knight = { is_alive = yes } #Check if the knight is still alive.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20350
		change_martial = 2
		if = { 
			limit = { 
				NOR = { 
					trait = robust 
					trait = feeble
				} 
			} 
			random = { 
				chance = 25
				add_trait = robust
			}
		}
		ai_chance = { 	 
			factor = 80
			modifier = { 
				factor = 0.5
				trait = indolent
			}
		}
	}
	option = {
		name = EVTOPTBHF20350
		prestige = 100
		if = { 
			limit = { 
				NOR = { 
					trait = willful 
					trait = timid
				} 
			} 
			random = { 
				chance = 25
				add_trait = willful
			}
		}
		ai_chance = { 	 
			factor = 20
			modifier = { 
				factor = 0
				trait = rowdy
			}
		}
	}
}

#King: A wandering priest has come to offer his services.
character_event = {
	id = HF.20351
	desc = EVTDESCHFA20351

	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = {
		event_target:coronation_ruler = { set_character_flag = flag_coronation_wandering_priest } #to avoid the same event happening twice during the coronation.

		create_random_priest = {
			random_traits = yes
			dynasty = none
			culture = ROOT
			religion = ROOT
			female = no
			age = 37
			attributes = {
				learning = 15
				diplomacy = 10
				}
			}
		new_character = {
			save_event_target_as = coronation_scholar
			remove_trait = slow
			remove_trait = imbecile
			remove_trait = dull
			
			remove_trait = mystic
			remove_trait = socializer
			remove_trait = gamer
			remove_trait = hedonist
			remove_trait = duelist
			remove_trait = strategist
			remove_trait = administrator
			remove_trait = architect
			remove_trait = gardener
			remove_trait = schemer
			remove_trait = impaler
			remove_trait = seducer
			remove_trait = seductress
			remove_trait = theologian
			remove_trait = scholar
			remove_trait = craven
			add_trait = brave
			random = { 
				chance = 10
				add_trait = zealous
			}
			random = { 
				chance = 30 
				add_trait = temperate
			}
			random = { 
				chance = 30 
				add_trait = diligent
			}
			random = { 
				chance = 40 
				add_trait = scholar
			}
			if = { 
				limit = { 
					has_dlc = "Mystics"
				}
				random_list = { 
					50 = { join_society = monastic_order_benedictine }
					50 = { join_society = monastic_order_dominican }
				}
			}
		}
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20351
		trigger = { 
			OR = { 
				learning = 10 
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		tooltip_info = learning
		change_learning = 2
		piety = 30
		show_portrait = coronation_scholar
		event_target:coronation_scholar = { 
			move_character = ROOT 
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20351
		show_portrait = coronation_scholar
		event_target:coronation_scholar = { 
			move_character = ROOT 
			opinion = {
				modifier = opinion_loyal_servant
				who = ROOT
				years = 100
			}
		}
		ai_chance = { 	 
			factor = 50
		}
	}
	option = {
		name = EVTOPTCHF20351
		hidden_tooltip = {
			event_target:coronation_scholar = { 
				death = {
					death_reason = death_missing
				}
			}
		}
		ai_chance = { 	 
			factor = 0
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Envious/Hateful Vassal guest becomes rival of host (or shows older rivalry).
character_event = {
	id = HF.20352
	desc = {
		trigger = {
			NOT = { is_rival = FROM }
		}
		text = EVTDESCHFA20352
	}
	desc = {
		trigger = {
			is_rival = FROM
		}
		text = EVTDESCHFB20352
	}

	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy
	hide_new = yes 

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}

	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_random_rivalry } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20352
		if = { 
			limit = { NOT = { is_rival = FROM } } 
			add_rival = FROM
			set_character_flag = flag_new_rivalry
		}
		event_target:coronation_ruler = { character_event = { id = HF.20353 } }
		ai_chance = { 	 
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20352
		trigger = { NOT = { is_rival = FROM } } 
		ai_chance = { 	 
			factor = 0
		}
	}
}

#King: one of your vassals has become your rival.
character_event = {
	id = HF.20353
	desc = {
		trigger = {
			FROM = { NOT = { has_character_flag = flag_new_rivalry } }
		}
		text = EVTDESCHFA20353
	}
	desc = {
		trigger = {
			FROM = { has_character_flag = flag_new_rivalry }
		}
		text = EVTDESCHFB20353
	}

	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy
	hide_new = yes 

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20353
		trigger = { diplomacy = 10 }
		tooltip_info = diplomacy
		FROM = { 
			clr_character_flag = flag_new_rivalry 
		}
		FROM = { character_event = { id = HF.20354 } }
		ai_chance = { 	 
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20353
		FROM = { clr_character_flag = flag_new_rivalry }
		add_rival = FROM
		ai_chance = { 	 
			factor = 0
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Rival Vassal: King has convinced you to not be his rival anymore.
character_event = {
	id = HF.20354
	desc = EVTDESCHFA20354
	hide_new = yes 

	picture = GFX_evt_scandal
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20354
		remove_rival = FROM
		ai_chance = { 	 
			factor = 100
		}
	}
}

#Secluded King: poor coronation makes you embarassed. Chance for paranoid or stressed.
character_event = {
	id = HF.20355
	desc = {
		trigger = { 
			war = no 
		}
		text = EVTDESCHFA20355
	}
	desc = {
		trigger = { 
			war = yes
		}
		text = EVTDESCHFB20355
		picture = GFX_evt_mounted_combat_day_hf
	}
	hide_new = yes 

	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_embarassed } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20355
		prestige = -75
		if = { 
			limit = { 
				NOT = { trait = paranoid } 
			} 
			add_trait = paranoid
			hidden_tooltip = { character_event = { id = 38275 } } 
		} 
		ai_chance = { 	 
			factor = 50
		}
	}
	option = {
		name = EVTOPTBHF20355
		if = { 
			limit = { 
				NOT = { trait = stressed } 
			} 
			random = { 
				chance = 50
				add_trait = stressed 
				hidden_tooltip = { character_event = { id = 38282 } } 
			}
		} 
		if = { 
			limit = { trait = stressed } 
			piety = -30
		} 
		ai_chance = { 	 
			factor = 50
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Secluded King: poor coronation makes the uninvited vassals unhappy.
character_event = {
	id = HF.20356
	desc = {
		trigger = { 
			war = no 
		}
		text = EVTDESCHFA20356
	}
	desc = {
		trigger = { 
			war = yes
		}
		text = EVTDESCHFB20356
		picture = GFX_evt_mounted_combat_day_hf
	}
	hide_new = yes 

	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_vassals } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20356
		custom_tooltip = { text = tooltip_EVTHF20356_A }
		prestige = -35
		hidden_tooltip = { 
			any_vassal = { 
				limit = {
					NOT = { is_councillor = yes }
				} 
				character_event = { id = HF.20357 }
			}
		}
		ai_chance = { 	 
			factor = 100
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Uninvited vassal of secluded coronation is unhappy with his liege.
character_event = {
	id = HF.20357
	desc = {
		trigger = { 
			war = no 
		}
		text = EVTDESCHFA20357
	}
	desc = {
		trigger = { 
			war = yes
		}
		text = EVTDESCHFB20357
		picture = GFX_evt_mounted_combat_day_hf
	}
	hide_new = yes 

	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20357
			opinion = {
				who = FROM
				modifier = opinion_offended
				months = 60
			}
		ai_chance = { 	 
			factor = 100
		}
	}
}

#Coronation_priest is unhappy with secluded coronation.
character_event = {
	id = HF.20358
	desc = { 
		trigger = {
			war = no 
			NOT = { event_target:coronation_priest = { higher_real_tier_than = DUKE } } 
		} 
		text = EVTDESCHFA20358
	}
	desc = { 
		trigger = { 
			event_target:coronation_priest = { higher_real_tier_than = DUKE } 
		} 
		text = EVTDESCHFB20358
	}
	desc = { 
		trigger = {
			war = yes
			event_target:coronation_priest = { higher_real_tier_than = DUKE } 
		} 
		text = EVTDESCHFC20358 #Papal Envoy.
		picture = GFX_evt_mounted_combat_day_hf
	}
	hide_new = yes 

	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_priest } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = {
			text = EVTOPTAHF20358
			trigger = {
				NOR = { event_target:coronation_priest = { higher_real_tier_than = DUKE } war = yes } 
			}
		}
		name = {
			text = EVTOPTAHF20358_B
			trigger = {
				war = no
				event_target:coronation_priest = { higher_real_tier_than = DUKE } 
			}
		}
		trigger = { diplomacy = 10 }
		if = { 
			limit = { event_target:coronation_priest = { higher_real_tier_than = DUKE } }
			event_target:coronation_priest = { 
				add_character_modifier = {
					name = mud_splatter
					months = 4
				}
			}
		}
		tooltip_info = diplomacy
		ai_chance = { 	 
			factor = 90
		}
	}
	option = {
		name = {
			text = EVTOPTBHF20358
			trigger = {
				NOR = { event_target:coronation_priest = { higher_real_tier_than = DUKE } war = yes } 
			}
		}
		name = {
			text = EVTOPTBHF20358_B
			trigger = {
				war = no
				event_target:coronation_priest = { higher_real_tier_than = DUKE } 
			}
		}
		piety = -75
		if = { 
			limit = { event_target:coronation_priest = { higher_real_tier_than = DUKE } }
			event_target:coronation_priest = { 
				add_character_modifier = {
					name = mud_splatter
					months = 4
				}
			}
		}
		event_target:coronation_priest = {
				show_scope_change = no	
			opinion = {
				who = FROM
				modifier = opinion_very_disappointed
				months = 240
			}
		}
		hidden_tooltip = { 
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				} 
				character_event = { id = HF.20359 }
			}
		}
		ai_chance = { 	 
			factor = 10
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Guests of secluded ceremony informed that coronation_priest dislikes it.
character_event = {
	id = HF.20359
	desc = { 
		trigger = {
			war = no
		} 
		text = EVTDESCHFA20359
	}
	desc = { 
		trigger = {
			war = yes
		} 
		text = EVTDESCHFB20359
		picture = GFX_evt_mounted_combat_day_hf
	}
	hide_new = yes 

	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests).
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20359
		ai_chance = { 	 
			factor = 100
		}
	}
}

#King depressed by secluded coronation, chance to lose ambitious or gain slothful.
character_event = {
	id = HF.20360
	desc = EVTDESCHFA20360
	hide_new = yes 

	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_ambitious } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20360
		trigger = { trait = ambitious }
		prestige = -35
		random = { 
			chance = 50
			remove_trait = ambitious
		}
		ai_chance = { 	
			factor = 50	
		}
	}
	option = {
		name = EVTOPTBHF20360
		if = { 
			limit = { trait = diligent } 
			random = { 
				chance = 50
				remove_trait = diligent 
				hidden_tooltip = { character_event = { id = 38319 } } 
			}
			break = yes
		}
		if = { 
			limit = { 
				NOR = { 
					trait = diligent 
					trait = slothful
				}  
			} 
			random = { 
				chance = 50
				add_trait = diligent 
				hidden_tooltip = { character_event = { id = 38256 } } 
			}
			break = yes
		}
		if = { 
			limit = { trait = slothful } 
			random = { 
				chance = 50
				piety = -50
			}
			break = yes
		}
		ai_chance = { 	
			factor = 50		
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Proud King humbled by secluded coronation.
character_event = {
	id = HF.20361
	desc = EVTDESCHFA20361
	hide_new = yes 

	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_proud } #to avoid the same event happening twice during the coronation.
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20361
		if = { 
			limit = { trait = proud } 
			remove_trait = proud
			add_trait = humble
			break = yes
		} 
		if = { 
			limit = { NOT = { trait = proud } } 
			add_trait = humble
		} 
		ai_chance = { 	
			factor = 50		
		}
	}
	option = {
		name = EVTOPTBHF20361
		piety = -100
		ai_chance = { 	
			factor = 50	
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#King in secluded Coronation mad at Steward.
character_event = {
	id = HF.20362
	desc = EVTDESCHFA20362
	hide_new = yes 

	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}
	immediate = { 
		event_target:coronation_ruler = { set_character_flag = flag_coronation_secluded_steward } #to avoid the same event happening twice during the coronation.
		event_target:coronation_ruler = { 
			random_courtier_or_vassal = { 
				limit = { 
					has_job_title = job_treasurer
				} 
				save_event_target_as = lazy_treasurer
			}
		}
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20362
			random_courtier_or_vassal = { 
				limit = { 
					has_job_title = job_treasurer
				} 
				add_rival = ROOT
				hidden_tooltip = { character_event = { id = HF.20363 } }
			}
		ai_chance = { 	
			factor = 100		
		}
	}
	option = {
		name = EVTOPTBHF20362
		prestige = -100
		ai_chance = { 	
			factor = 0	
		}
	}
	after = { hidden_tooltip = { event_target:coronation_ruler = { character_event = { id = HF.20365 days = 3 random = 5 } } } } #Second row of random events, else coronation itself.
}

#Notify Steward of new rivalry.
character_event = {
	id = HF.20363
	desc = EVTDESCHFA20363
	hide_new = yes 

	picture = GFX_evt_lunatic
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
	}

	is_triggered_only = yes
	
	option = {
		name = EVTOPTAHF20363
		FROM = { add_rival = ROOT }
		ai_chance = { 	
			factor = 100		
		}
	}
}

#HF.20364 already taken by previous doubled event.

#Hidden event fired twice at different days, holding the scripted_effect containing the long random_list of possible events that can happen during the ceremony.
character_event = {
	id = HF.20365
	hide_window = yes

	trigger = { 
		event_target:coronation_ruler = {
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
			NOR = {
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			} 
		} 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crownied is still alive.
		#NOT = { check_variable = { which = coronation_count value = 2 } } #Stop at second row.
	}

	is_triggered_only = yes
	
	immediate = {
		if =  { 
			limit = { 
				NOT = { check_variable = { which = coronation_count value = 2 } } 
			}
			random_coronation_events_effect = yes	
		}
		if =  { 
			limit = { 
				check_variable = { which = coronation_count value = 2 } 
			}
			character_event = { id = HF.20366 days = 15 } #THE CORONATION ITSELF.
		}
		change_variable = { which = coronation_count value = 1 }
	}
}

############################################################################

#CORONATION EVENT
character_event = {
	id = HF.20366
	title = EVTTITLE20366
	desc = {
		trigger = {
			ROOT = { 
				war = no
				OR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESCHFA20366		# Top localization for an Holy Roman Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				tier = EMPEROR
				NOR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFB20366		# Localization for any adult Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				tier = EMPEROR
				NOR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFC20366		# Localization for any child Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				tier = KING
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFD20366		# Localization for any adult King crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				tier = KING
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFE20366		# Localization for any child King crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
				NOT = { has_character_flag = flag_crowned_by_pope }
				age = 16
			}
		}
		text = EVTDESCHFF20366		# Localization for any adult ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
				NOT = { has_character_flag = flag_crowned_by_pope }
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFG20366		# Localization for any child ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFH20366		# Localization for any adult ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFI20366		# Localization for any child ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = no
				has_character_flag = flag_secluded_coronation
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
		text = EVTDESCHFL20366		# Localization for any ruler crowned by a Bishop or Priest in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			ROOT = { 
				war = yes
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
		text = EVTDESCHFM20366		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}

	desc = {
		trigger = {
			ROOT = { 
				war = yes
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESCHFN20366		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}


	picture = GFX_evt_found_hre
	border = GFX_event_normal_frame_religion
	hide_new = yes

	trigger = { 
		NOT = { has_character_flag = flag_being_coronated }
		event_target:coronation_ruler = { 
			OR = {
				religion = catholic
				religion = fraticelli
			}
			OR = {
				has_character_flag = flag_crowned_by_priest
				has_character_flag = flag_crowned_by_bishop
				has_character_flag = flag_crowned_by_pope
			}
			NOR = { 
				trait = crowned_by_myself
				trait = crowned_by_pope
				trait = crowned_by_bishop
				trait = crowned_by_priest
			} 
		}
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		event_target:coronation_ruler = { character = ROOT }
	}

	is_triggered_only = yes

	immediate = { 

		if = {
			limit = {
				has_character_flag = flag_secluded_coronation
				war = no
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = {
				has_character_flag = flag_extravagant_coronation
			}
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}
		ROOT = {
			remove_character_modifiers = { modifier = uncrowned_modifier amount = 30 } 
			set_variable = { which = uncrowned_count value = 0 }
			set_character_flag = flag_being_coronated #Safety check to avoid double event.
		}
		ROOT = { save_persistent_event_target = { name = coronation_priest_per scope = event_target:coronation_priest } } #Needed to localize the trait properly.
	} 
	option = { # Napoleon option
		name = EVTOPTZHF20366
		trigger = { 
			tier = EMPEROR
			age = 16 # Has to be strong enough to grab the crown from the Pope's clutches.
			event_target:coronation_priest = { has_landed_title = k_papal_state }
			has_character_flag = flag_extravagant_coronation				#Only allowed to screw everything up if you have spent the most money in it already.
			OR = { 
				trait = lunatic
				trait = possessed
				AND = { 
					trait = ambitious
					primary_title = { has_law = imperial_administration } 
				}
				society_member_of = the_satanists
			}
		}
		add_trait = crowned_by_myself
		add_character_modifier = {
			name = extravagant_coronation
			days = 7300 #20 years
		}
		#Notify all guests, then conclude the ceremony.
		hidden_tooltip = {  
			character_event = { id = HF.20371 } #Self-Coronation scandal.
			character_event = { id = HF.20369 days = 3 random = 3 } #wrap up, clear all flags.
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				character_event = { id = HF.20371 } #Self-Coronation event for guests.
				character_event = { id = HF.20370 days = 3 random = 3 } #wrap up, clear all flags.
			}
			any_vassal = { 
				limit = { 
					NOT = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
					}
				}
				character_event = { id = HF.20371 } #Self-Coronation event for vassals who did not attend to the ceremony.
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				character_event = { id = HF.20371 } #Coronation event for guests.
				character_event = { id = HF.20370 days = 3 random = 3 } #wrap up, clear all flags.
			} 
			if = {
				limit = {
					ai = no
				}
				set_character_flag = achievement_leglise_cest_moi
			}
		}

		ai_chance = { 	
			factor = 5		
		} 
	} 
	
	option = {
		name = EVTOPTAHF20366
		#Assign proper trait.
		if = { 
			limit = { 
				has_character_flag = flag_crowned_by_pope 
			} 
			custom_tooltip = { text = tooltip_gain_crowned_by_pope }
			hidden_tooltip = { add_trait = crowned_by_pope }
		}
		if = { 
			limit = { 
				has_character_flag = flag_crowned_by_bishop 
			} 
			custom_tooltip = { text = tooltip_gain_crowned_by_bishop }
			hidden_tooltip = { add_trait = crowned_by_bishop }
		}
		if = { 
			limit = { 
				has_character_flag = flag_crowned_by_priest
			} 
			custom_tooltip = { text = tooltip_gain_crowned_by_priest }
			hidden_tooltip = { add_trait = crowned_by_priest }
		}

		#Assign possible modifier.
		if = { 
			limit = { 
				war = no
				has_character_flag = flag_secluded_coronation 
				NOT = { has_character_flag = flag_crowned_by_pope } 
			} 
			add_character_modifier = {
				name = crowned_in_barn
				days = -1
			}
		}
		if = { 
			limit = { 
				war = yes
				has_character_flag = flag_secluded_coronation 
			} 
			add_character_modifier = {
				name = crowned_in_war
				days = -1
			}
		}
		if = { 
			limit = { 
				has_character_flag = flag_extravagant_coronation 
				NOT = { has_character_flag = flag_crowned_by_priest } 
			} 
			add_character_modifier = {
				name = extravagant_coronation
				days = 7300
			}
		}
		#Notify all guests, then conclude the ceremony.
		hidden_tooltip = {  
			character_event = { id = HF.20369 days = 3 random = 3 } #wrap up, clear all flags.
			any_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				character_event = { id = HF.20367 } #Coronation event for guests.
				character_event = { id = HF.20370 days = 3 random = 3 } #wrap up, clear all flags.
			}
			any_vassal = { 
				limit = { 
					NOT = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
					}
				}
				character_event = { id = HF.20368 } #Smaller notification for vassals who did not attend to the ceremony.
			}
			any_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
				}
				character_event = { id = HF.20367 } #Coronation event for guests.
				character_event = { id = HF.20370 days = 3 random = 3 } #wrap up, clear all flags.
			} 
		} 
		ai_chance = { 	
			factor = 95		
		}
	}
	after= { 	
		hidden_tooltip = { remove_character_modifier = coronation_request_cooldown }
		clr_character_flag = flag_being_coronated
	}
}

#CORONATION EVENT (for guests)
character_event = {
	id = HF.20367
	title = EVTTITLE20366
	desc = {
		trigger = {
			FROM = { 
				war = no
				OR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESCHFA20367		# Top localization for an Holy Roman Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				tier = EMPEROR
				NOR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFB20367		# Localization for any adult Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				tier = EMPEROR
				NOR = { 
					has_landed_title = e_hre 
					has_landed_title = e_france
				}
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFC20367		# Localization for any child Emperor crowned by the Pope (not in a barn).
		picture = GFX_evt_found_hre
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				tier = KING
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFD20367		# Localization for any adult King crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				tier = KING
				NOT = { has_character_flag = flag_secluded_coronation }
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFE20367		# Localization for any child King crowned by the Pope (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
				NOT = { has_character_flag = flag_crowned_by_pope }
				age = 16
			}
		}
		text = EVTDESCHFF20367		# Localization for any adult ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				NOT = { has_character_flag = flag_secluded_coronation }
				NOT = { has_character_flag = flag_crowned_by_pope }
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFG20367		# Localization for any child ruler crowned by a Bishop or Priest (not in a barn).
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				age = 16
			}
		}
		text = EVTDESCHFH20367		# Localization for any adult ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				has_character_flag = flag_secluded_coronation
				has_character_flag = flag_crowned_by_pope
				NOT = { age = 16 }
			}
		}
		text = EVTDESCHFI20367		# Localization for any child ruler crowned by the Pope in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = no
				has_character_flag = flag_secluded_coronation
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
		text = EVTDESCHFL20367		# Localization for any ruler crowned by a Bishop or Priest in a barn.
		picture = GFX_evt_a_crowning_ceremony
	}
	desc = {
		trigger = {
			FROM = { 
				war = yes
				NOT = { has_character_flag = flag_crowned_by_pope }
			}
		}
		text = EVTDESCHFM20367		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}
	desc = {
		trigger = {
			FROM = { 
				war = yes
				has_character_flag = flag_crowned_by_pope
			}
		}
		text = EVTDESCHFN20367		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		has_opinion_modifier = { 
			who = event_target:coronation_ruler 
			modifier = opinion_coronation_guest 
		}
	}

	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				FROM = { war = no has_character_modifier = crowned_in_barn }
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = {
				FROM = { has_character_modifier = extravagant_coronation }
			}
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}
	}

	option = {
		name = EVTOPTAHF20367

		#Assign scaled piety.
		if = { 
			limit = { 
				FROM = { has_character_flag = flag_crowned_by_pope } 
			} 
			piety = 10
		}
		if = { 
			limit = { 
				FROM = { has_character_flag = flag_crowned_by_bishop } 
			} 
			piety = 20
		}
		if = { 
			limit = { 
				FROM = { has_character_flag = flag_crowned_by_priest } 
			} 
			piety = 30
		}

		#Assign scaled prestige.
		if = { 
			limit = { 
				FROM = { 
					has_character_flag = flag_secluded_coronation 
					NOT = { has_character_flag = flag_crowned_by_pope } 
				}  
			} 
			prestige = -25
		}
		if = { 
			limit = { 
				FROM = { has_character_flag = flag_regular_coronation }  
			} 
			prestige = 50
		}
		if = { 
			limit = { 
				FROM = { 
					has_character_flag = flag_extravagant_coronation 
					NOT = { has_character_flag = flag_crowned_by_pope } 
				} 
			} 
			prestige = 75
		}
		if = { 
			limit = { 
				FROM = { 
					has_character_flag = flag_extravagant_coronation 
					has_character_flag = flag_crowned_by_pope 
				}
			} 
			prestige = 100
		}
		ai_chance = { 	
			factor = 100		
		}
	}
}

#Notifications for vassals who did not attend.
character_event = {
	id = HF.20368
	title = EVTTITLE20366
	desc = {
		trigger = {
			ROOT = { 
				war = no
			}
		}
		text = EVTDESCHFA20368
	}
	desc = {
		trigger = {
			ROOT = { 
				war = yes
			}
		}
		text = EVTDESCHFA20368
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	trigger = { 
		event_target:coronation_priest = { is_alive = yes } #Check if the priest supposed to be crowning you is still alive.
		event_target:coronation_ruler = { is_alive = yes } #Check if the ruler supposed to be crowned is still alive. (check for guests)
		vassal_of = FROM
	}
	
	immediate = {
		if = {
			limit = {
				FROM = { has_character_modifier = crowned_in_barn war = no }
			}
			sound_effect = coronation_barn
		}
		else_if = {
			limit = {
				FROM = { has_character_modifier = extravagant_coronation }
			}
			sound_effect = coronation_extravagant
		}
		else = {
			sound_effect = coronation_normal
		}
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20368
		ai_chance = { 	
			factor = 100		
		}
	}
}

#Crowned King: the Coronation ceremony has concluded. END OF THE LINE. HIDDEN FOR REDUNDANCY.
character_event = {
	id = HF.20369
	desc = EVTDESCHFA20369
	hide_window = yes

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	#option = {
	#	name = EVTOPTAHF20369
	immediate = {
		hidden_tooltip = { #Post-ceremony flavor.
			if = { 
				limit = { has_character_modifier = crowned_in_barn } 
				random = { 
					chance = 30 
					character_event = { id = HF.20388 days = 100 random = 100 } #Emperor humbled by Crowning in a barn.
				}
			}
			random = { 
				chance = 30 
			} 
			if = { 
				limit = { has_character_flag = flag_extravagant_coronation } 
				random = { 
					chance = 30 
					character_event = { id = HF.20389 days = 50 random = 50 } #Peasants are still celebrating after the coronation. What do you do?
				}
			}
			if = { 
				limit = { has_character_flag = flag_extravagant_coronation } 
				random = { 
					chance = 30 
					character_event = { id = HF.20390 days = 50 random = 50 } #Word of great coronation spreads, giving additional prestige.
				}
			}
			if = { 
				limit = { has_character_flag = flag_extravagant_coronation } 
				random = { 
					chance = 30 
					character_event = { id = HF.20391 days = 150 random = 150 } #Capital economy increased because of coronation.
				}
			}
		}
		hidden_tooltip = { remove_character_modifier = out_traveling }
		hidden_tooltip = { remove_trait = travelling }
		hidden_tooltip = { set_variable = { which = coronation_count value = 0 } }

		clr_character_flag = flag_preparing_coronation 
		clr_character_flag = flag_antipope_for_coronation 
		clr_character_flag = flag_excommunicated_for_coronation 
		clr_character_flag = flag_pepin_for_coronation 
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation

		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent 
		clr_character_flag = flag_coronation_gain_ambitious 
		clr_character_flag = flag_coronation_haughty_child 
		clr_character_flag = flag_coronation_priest_approves 
		clr_character_flag = flag_coronation_hre_talk 
		clr_character_flag = flag_coronation_pope_talk 
		clr_character_flag = flag_coronation_foreign_teacher 
		clr_character_flag = flag_coronation_priest_disapproves 
		clr_character_flag = flag_coronation_diplomatic_incident 
		clr_character_flag = flag_coronation_cynic_taunts 
		clr_character_flag = flag_coronation_wandering_knight 
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry 
		clr_character_flag = flag_coronation_secluded_embarassed 
		clr_character_flag = flag_coronation_secluded_vassals 
		clr_character_flag = flag_coronation_secluded_priest 
		clr_character_flag = flag_coronation_secluded_ambitious 
		clr_character_flag = flag_coronation_secluded_proud 
		clr_character_flag = flag_coronation_secluded_steward 
	}
}

#Coronation Guest: the Coronation ceremony has concluded. END OF THE LINE.
character_event = {
	id = HF.20370
	desc = {
		trigger = {
			FROM = { 
				war = no
			}
		}
		text = EVTDESCHFB20370
	}
	desc = {
		trigger = {
			FROM = { 
				war = yes
			}
		}
		text = EVTDESCHFC20370		# War Coronation description.
		picture = GFX_evt_mounted_combat_day_hf
	}

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20370
		if = { 
			limit = { trait = travelling }
			remove_trait = travelling
		}
		if = { 
			limit = { has_character_modifier = out_traveling }
			remove_character_modifier = out_traveling
		}
		hidden_tooltip = {
			remove_opinion = {
				modifier = opinion_coronation_guest
				who = FROM
			}
		}
		if = { 
			limit = { 
				FROM = { has_character_modifier = extravagant_coronation }
				independent = yes
				higher_real_tier_than = DUKE
				OR = { 
					has_character_modifier = crowned_in_barn
					NOR = { 
						trait = crowned_by_priest
						trait = crowned_by_bishop
						trait = crowned_by_pope
						trait = crowned_by_myself
					}
				}
			}
			hidden_tooltip = { character_event = { id = HF.20392 days = 50 random = 50 } } #Envious ruler who isn't crowned or is crowned in barn is upset that his host had a good coronation.
		}

	}
}

#Crazy Napoleon ruler snatched the crown from the Pope's hands and crowned himself Emperor.
character_event = {
	id = HF.20371
	title = EVTTITLE20371
	desc = {
		trigger = {
			ROOT = { character = FROM } #Desc for Ruler.
		}
		text = EVTDESCHFA20371
	}
	desc = {
		trigger = {
			ROOT = { 
				has_opinion_modifier = { #Desc for Guests
					who = event_target:coronation_ruler 
					modifier = opinion_coronation_guest 
				}
			}
		}
		text = EVTDESCHFB20371		
	}

	desc = {
		trigger = {
			ROOT = { 
				vassal_of = FROM
				NOT = { 
					has_opinion_modifier = { #Desc for Vassals who did not attend.
						who = event_target:coronation_ruler 
						modifier = opinion_coronation_guest 
					}
				}
			}
		}
		text = EVTDESCHFC20371		
	}
	picture = GFX_evt_a_crowning_ceremony
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	trigger = {
		OR = { 
			character = FROM #King
			has_opinion_modifier = { #Guests
				who = event_target:coronation_ruler 
				modifier = opinion_coronation_guest 
			}
			vassal_of = FROM #Vassals
		}

	}

	option = {
		name = EVTOPTAHF20371
		trigger = {
			ROOT = { character = FROM }
		}
		add_trait = excommunicated
		prestige = 400
		piety = -250
	}
	option = {
		name = EVTOPTBHF20371
		trigger = {
			ROOT = { NOT = { character = FROM } }
			ROOT = { 
				has_opinion_modifier = { 
					who = event_target:coronation_ruler 
					modifier = opinion_coronation_guest 
				}
			}
		}
	}
	option = {
		name = EVTOPTCHF20371
		trigger = {
			ROOT = { NOT = { character = FROM } }
			ROOT = { 
				vassal_of = FROM
				NOT = { 
					has_opinion_modifier = { #Desc for Vassals who did not attend.
						who = event_target:coronation_ruler 
						modifier = opinion_coronation_guest 
					}
				}
			}
		}
	}
}

###################################################################################################################

#On_start event to assign crowned_by_traits to existing rulers, so as to prevent a cascade of coronation ceremonies at the beginning of every game.
character_event = {
	id = HF.20372
	hide_window = yes

	is_triggered_only = yes

	trigger = { 
		has_landed_title = k_papal_state
		is_save_game = no
		has_dlc = "Holy Fury"

	}
	immediate = {
		set_global_flag = flag_crowns_delivered
		any_playable_ruler = { 
			limit = { 
				age = 16
				religion = catholic 
				is_feudal = yes
				NOT = { government = order_government }
				higher_real_tier_than = DUKE
				NOT = { has_character_flag = is_charlemagne }
				NOT = { has_character_flag = is_carloman }
				NOT = { trait = crowned_by_priest }
				NOT = { trait = crowned_by_bishop }
				NOT = { trait = crowned_by_pope }
				NOT = { trait = crowned_by_myself }
				is_vice_royalty = no
			}
			random_list = { 
				#Crowned by Pope
				#Crowned by Bishop
				#Crowned by Priest

				10 = { 
					modifier = { #Excommunicated rulers, possessed rulers, or rulers under an Antipope are never assigned Crowned by the Pope.
						factor = 0
						OR = { 
							trait = excommunicated
							trait = possessed 
							NOT = { religion_head = { has_landed_title = k_papal_state } }
							has_landed_title = e_latin_empire #Disavowed historically.
						}
					}
					modifier = { #More distant/Less powerful Kingdom less likely to be crowned by the Pope.
						factor = 0.5
						NOR = {  
							has_landed_title = k_france
							has_landed_title = k_burgundy
							has_landed_title = k_aquitaine
							has_landed_title = k_germany
							has_landed_title = k_lotharingia
							has_landed_title = k_italy
							has_landed_title = k_sicily
							has_landed_title = k_naples
						} 
					}
					modifier = { #If the Pope disliked him, less likely to be crowned by him.
						factor = 0.5
						NOT = {  
							reverse_opinion = { 
								who = ROOT
								value = 0 
							} 
						} 
					}
					modifier = { #Historically more likely.
						factor = 10
						OR = {  
							has_landed_title = k_italy
							has_landed_title = e_hre
						} 
					}
				save_persistent_event_target = { name = coronation_priest_per scope = ROOT } #Needed to localize the trait properly.
				add_trait = crowned_by_pope
				}
				80 = { 
					modifier = { #Checking if there is no Antipope, and you are not excommunicated, go for the Pope.
						factor = 0.1
						NOT = { trait = excommunicated }
						NOT = { trait = possessed }
						religion_head = { has_landed_title = k_papal_state } 
						tier = EMPEROR
					}
					modifier = { #Checking if Emperor, Bishop Coronation unavailable when without investiture law.
						factor = 0
						tier = EMPEROR
						NOT = { primary_title = { has_law = investiture_law_0 } }
					}
					modifier = { #Checking if there is an available powerful theocrat.
						factor = 0
						NOT = { 
							any_realm_character = { 
								is_theocracy = yes 
								religion = ROOT
								OR = { 
									higher_real_tier_than = BARON 
									has_minor_title = title_cardinal
									has_minor_title = title_fraticelli_cardinal
									any_claim = { title = k_papal_state } #Antipope
									any_claim = { title = d_fraticelli } #Antipope
								}
								NOT = { has_landed_title = k_papal_state }
								NOT = { has_landed_title = d_fraticelli }
							}
						} 
					}
					character_event = { id = HF.20373 }
				}
				10 = { 
					modifier = { #Holy Roman Emperors always crowned by somebody important.
						factor = 0
						NOT = { trait = excommunicated }
						NOT = { trait = possessed }
						NOT = { has_landed_title = e_latin_empire }
						tier = EMPEROR
					}
					modifier = { #Respectable Kings are crowned by Bishops.
						factor = 0
						NOT = { trait = excommunicated }
						NOT = { trait = possessed }
						tier = KING
						any_realm_character = { 
							is_theocracy = yes 
							religion = ROOT
							OR = { 
								higher_real_tier_than = BARON 
								has_minor_title = title_cardinal
								has_minor_title = title_fraticelli_cardinal
								any_claim = { title = k_papal_state } #Antipope
								any_claim = { title = d_fraticelli } #Antipope
							}
							NOT = { has_landed_title = k_papal_state }
							NOT = { has_landed_title = d_fraticelli }
						}
					}
					add_trait = crowned_by_priest
				}
			}
			random_list = { #Second list to determine which modifier.
				40 = { 
					modifier = {
						factor = 0.1
						OR = { 
							trait = excommunicated
							trait = possessed 
						}
					}
					modifier = {
						factor = 0.5
						tier = KING
					}
					modifier = {
						factor = 2
						trait = crowned_by_pope
					}
					if = { 
						limit = { NOT = { ruled_years = 20 } }
						add_character_modifier = {
							name = extravagant_coronation
							days = 6000 #Has probably already ruled for a while.
						}
					}
				}
				50 = { 
				}
				10 = { 
					add_character_modifier = {
						name = crowned_in_barn
						days = -1
					}
				}
			}
		}
	}
}
#Scoping to a powerful theocrat.
character_event = {
	id = HF.20373
	hide_window = yes

	is_triggered_only = yes

	immediate = { 
		random_realm_character = { 
			limit = { 
			is_theocracy = yes 
			religion = ROOT
			OR = { 
				higher_real_tier_than = BARON 
				has_minor_title = title_cardinal
				has_minor_title = title_fraticelli_cardinal
				any_claim = { title = k_papal_state } #Antipope
				any_claim = { title = d_fraticelli } #Antipope
				}
			NOT = { has_landed_title = k_papal_state }
			NOT = { has_landed_title = d_fraticelli }
			}
			ROOT = { save_persistent_event_target = { name = coronation_priest_per scope = PREV } }
		}
		add_trait = crowned_by_bishop
	}
}

#On_death: ruler who died uncrowned will gain uncrowned trait, so that his portrait doesn't default to the royal/imperial crown.
character_event = {
	id = HF.20374
	hide_window = yes

	only_rulers = yes

	is_triggered_only = yes

	trigger = { 
		higher_real_tier_than = DUKE
		OR = { 
			religion = catholic
			religion = fraticelli
		}
		NOR =  { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}
	immediate = { 
		add_trait = uncrowned
	}
}

#Five-yearly random bad events for uncrowned rulers.
character_event = {
	id = HF.20375
	hide_window = yes


	only_rulers = yes
	min_age = 16

	is_triggered_only = yes

	trigger = { 
		has_dlc = "Holy Fury"
		is_feudal = yes
		higher_real_tier_than = DUKE
		ruled_years = 5
		OR = { 
			religion = catholic
			religion = fraticelli
		}
		NOR =  { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			trait = papal_icon
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
			government = order_government 
		}
	}

	immediate = { 
		#Random negative flavour.
		random_list = { 
			20 = { 
				character_event = { id = HF.20376 days = 100 random = 100 } #Peasants are upset.
			}
			20 = { 
				modifier = { 
					factor = 0
					NOT	= { 
						any_vassal = { 
							is_theocracy = yes
							count = 2
						}
					}
				}
				character_event = { id = HF.20377 days = 100 random = 100 } #Priests are upset.
			}
			20 = { 
				modifier = { 
					factor = 0
					is_married = no
				}
				modifier = { 
					factor = 0
					spouse = { 
						NOR = { 
							religion = catholic
							religion = fraticelli
						}
					}
				}
				modifier = { 
					factor = 1.75
					spouse = { 
						trait = wroth
					}
				}
				modifier = { 
					factor = 1.75
					spouse = { 
						OR = { 
							trait = crowned_by_priest
							trait = crowned_by_bishop
							trait = crowned_by_pope
							trait = crowned_by_myself
						}
					}
				}
				modifier = { 
					factor = 1.5
					spouse = { 
						higher_real_tier_than = ROOT
					}
				}
				spouse = { character_event = { id = HF.20378 days = 100 random = 100 } } #Spouse is upset.
			}
			20 = { 
				modifier = { 
					factor = 0
					NOT = { any_courtier_or_vassal = { has_job_title = job_chancellor } }
				}
				modifier = { 
					factor = 1.75
					any_courtier_or_vassal = { 
						has_job_title = job_chancellor 
						trait = wroth
					}
				}
				random_courtier_or_vassal = { 
					limit = { has_job_title = job_chancellor }
					character_event = { id = HF.20384 days = 100 random = 100 } #Chancellor is upset.
				} 
			}
			10 = { 
				modifier = { 
					factor = 0
					NOT = { any_courtier_or_vassal = { has_job_title = job_spiritual } }
				}
				modifier = { 
					factor = 0.25
					any_courtier_or_vassal = { 
						has_job_title = job_spiritual 
						dynasty = ROOT
					}
				}
				modifier = { 
					factor = 1.75
					any_courtier_or_vassal = { 
						has_job_title = job_spiritual 
						trait = zealous
					}
				}
				modifier = { 
					factor = 1.75
					any_courtier_or_vassal = { 
						has_job_title = job_spiritual 
						trait = diligent
					}
				}
				modifier = { 
					factor = 1.75
					any_courtier_or_vassal = { 
						has_job_title = job_spiritual 
						trait = temperate
					}
				}
				modifier = { 
					factor = 1.75
					any_courtier_or_vassal = { 
						has_job_title = job_spiritual 
						trait = wroth
					}
				}
				random_courtier_or_vassal = { 
					limit = { has_job_title = job_spiritual }
					character_event = { id = HF.20386 days = 100 random = 100 } #Court chaplain resigns in protest.
				} 
			}
			10 = { 
				modifier = { 
					factor = 0.5
					tier = EMPEROR
				}
				modifier = { 
					factor = 0.5
					has_landed_title = e_hre
				}
				modifier = { 
					factor = 1.5
					piety = 200
				}
				modifier = { 
					factor = 1.5
					piety = 300
				}
				modifier = { 
					factor = 1.5
					piety = 400
				}
				modifier = { 
					factor = 1.5
					piety = 500
				}
				modifier = { 
					factor = 1.5
					piety = 600
				}
				modifier = { 
					factor = 1.5
					piety = 700
				}
				modifier = { 
					factor = 1.5
					piety = 800
				}
				modifier = { 
					factor = 1.5
					piety = 900
				}
				modifier = { 
					factor = 2
					piety = 1000
				}
				#Nothing happens.
			}
		}
	}
}

################################################################################################################

#Generic Flavor events related to coronation and crowns.

#Peasants are restless because ruler is uncrowned.
character_event = {
	id = HF.20376
	desc = EVTDESCHFA20376

	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_diplomacy

	only_rulers = yes

	trigger = { 
		has_dlc = "Holy Fury"
		NOR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			trait = papal_icon
		}
		OR = { 
			religion = catholic
			religion = fraticelli
		}
		capital_scope = { religion = ROOT }
		higher_real_tier_than = DUKE
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20376
		capital_scope = {
			add_province_modifier = {
				name = peasant_unrest
				duration = 365
				stacking = yes
			}
		}
		ai_chance = { 	
			factor = 100		
		}
	}
}

#Church vassals upset because of uncrowned ruler.
character_event = {
	id = HF.20377
	desc = EVTDESCHFA20377

	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_diplomacy

	only_rulers = yes

	trigger = { 
		has_dlc = "Holy Fury"
		NOR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			trait = papal_icon
		}
		OR = { 
			religion = catholic
			religion = fraticelli
		}
		higher_real_tier_than = DUKE
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20377
		trigger = { learning = 12 }
		tooltip_info = learning
		custom_tooltip = { text = tooltip_explain_coronation }
		piety = 50
		ai_chance = { 	
			factor = 100		
		}
	}
	option = {
		name = EVTOPTBHF20377
		trigger = { diplomacy = 12 }
		tooltip_info = diplomacy
		custom_tooltip = { text = tooltip_explain_coronation_2 }
		prestige = 75
		ai_chance = { 	
			factor = 100		
		}
	}
	option = {
		name = EVTOPTCHF20377
		trigger = { wealth = 100 }
		custom_tooltip = { text = tooltip_bribe_church }
		wealth = -100
		religion_head = { wealth = 200 }
		ai_chance = { 	
			factor = 50		
		}
	}
	option = {
		name = EVTOPTDHF20377
		any_vassal = {
			limit = { 
				is_theocracy = yes
				religion = ROOT
			 }
			opinion = {
				modifier = opinion_uncrowned_ruler
				years = 1
				who = ROOT
			}
		}
		ai_chance = { 	
			factor = 50		
		}
	}
}

#Spouse: Your spouse is still not crowned.
character_event = {
	id = HF.20378
	desc = EVTDESCHFA20378

	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		has_dlc = "Holy Fury"
		FROM = {
			is_married = ROOT
			NOR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				trait = papal_icon
			}
			OR = { 
				religion = catholic
				religion = fraticelli
			}
			higher_real_tier_than = DUKE
		}
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20378
		custom_tooltip = { text = spouse_informed_uncrowned }
		opinion = {
			modifier = opinion_uncrowned_failure
			years = 5
			who = FROM
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20379 } } }
		ai_chance = { 	
			factor = 75	
		}
	}
	option = {
		name = EVTOPTBHF20378
		ai_chance = { 	
			factor = 25
			modifier = 	{ 
				factor = 0
				NOT = { trait = kind }
				NOT = { trait = patient }
			}
		}
	}
}
#Ruler: Your spouse is upset.
character_event = {
	id = HF.20379
	desc = EVTDESCHFA20379

	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = { #Look who's talking.
		name = EVTOPTAHF20379
		trigger = { 
			FROM = { 
				is_ruler = yes 
				higher_real_tier_than = DUKE
				NOR = { 
					trait = crowned_by_priest
					trait = crowned_by_bishop
					trait = crowned_by_pope
					trait = crowned_by_myself
					trait = papal_icon
				}
			} 
		}
		tooltip = {
			FROM = {
				prestige = -75
				opinion = {
					modifier = opinion_uncrowned_failure
					years = 5
					who = ROOT
				}
			}
		}
		add_rival = FROM
		hidden_tooltip = { FROM = { character_event = { id = HF.20380 } } }
		ai_chance = { 	
			factor = 25
			modifier = { 
				factor = 3
				trait = envious
			}
			modifier = { 
				factor = 3
				trait = proud
			}
		}
	}
	option = {
		name = EVTOPTBHF20379
		trigger = { diplomacy = 15 }
		tooltip_info = diplomacy
		prestige = 75
		FROM = {
				show_scope_change = no	
			remove_opinion = {
				modifier = opinion_uncrowned_failure
				who = ROOT
			}
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20381 } } }
		ai_chance = { 	
			factor = 50
		}
	}
	option = {
		name = EVTOPTCHF20379
		trigger = { 
			OR = { trait = lustful 
				is_lover = FROM
			} 
			FROM = { 
				NOR = { 
					trait = chaste 
					trait = celibate
				} 
			}
		}
		tooltip_info = lustful
		piety = -20
		tooltip = {
			FROM = {
				show_scope_change = no	
				remove_opinion = {
					modifier = opinion_uncrowned_failure
					who = ROOT
				}
			}
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20382 } } }
		ai_chance = { 	
			factor = 50
		}
	}
	option = {
		name = EVTOPTDHF20379
		tooltip = {
			FROM = {
				opinion = {
					modifier = opinion_uncrowned_failure
					years = 5
					who = ROOT
				}
			}
		}
		ai_chance = { 	
			factor = 25
			modifier = 	{ 
				factor = 0
				NOT = { trait = kind }
				NOT = { trait = patient }
			}
		}
	}
}
#Spouse: Your spouse pointed out that you aren't crowned either.
character_event = {
	id = HF.20380
	desc = EVTDESCHFA20380

	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20380
		prestige = -75
		add_rival = FROM
		ai_chance = { 	
			factor = 100
		}
	}
}

#Spouse: Used diplomacy on you.
character_event = {
	id = HF.20381
	desc = EVTDESCHFA20381

	picture = GFX_evt_daughter_asking_father
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20381
		tooltip = {
			remove_opinion = {
				modifier = opinion_uncrowned_failure
				who = FROM
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Spouse: Used sex on you.
character_event = {
	id = HF.20382
	desc = EVTDESCHFA20382

	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20382
		remove_opinion = {
			modifier = opinion_uncrowned_failure
			who = FROM
		}
		ai_chance = { 	
			factor = 90
			modifier = { 
				factor = 1.5
				FROM = { has_fair_trait_trigger = yes }
			}
			modifier = { 
				factor = 0.5
				FROM = { has_ugly_trait_trigger = yes }
			}
			modifier = { 
				factor = 0.25
				FROM = { trait = inbred }
			}
			modifier = { 
				factor = 0.5
				FROM = { trait = hunchback }
			}
			modifier = { 
				factor = 0.5
				FROM = { trait = harelip }
			}
			modifier = { 
				factor = 0.5
				NOT = { age = 40 }
				FROM = { age = 40 }
			}
			modifier = { 
				factor = 0.25
				NOT = { age = 60 }
				FROM = { age = 60 }
			}
			modifier = { 
				factor = 0.2
				any_lover = { NOT = { character = FROM } }
			}
			modifier = { 
				factor = 0
				is_rival = FROM
			}
			modifier = { 
				factor = 0
				trait = homosexual
			}
		}
	}
	option = {
		name = EVTOPTBHF20382
		hidden_tooltip = { FROM = { character_event = { id = HF.20383 } } }
		ai_chance = { 	
			factor = 10
			modifier = 	{ 
				factor = 0
				trait = lustful
			}
		}
	}
}

#Ruler: Spouse did not care for sex.
character_event = {
	id = HF.20383
	desc = EVTDESCHFA20383

	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20383
		tooltip = {
			opinion = {
				modifier = opinion_uncrowned_failure
				who = FROM
				years = 5
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Chancellor: Should remember that liege is still uncrowned.
character_event = {
	id = HF.20384
	desc = EVTDESCHFA20384

	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	trigger = { 
		has_dlc = "Holy Fury"
		liege = {
			NOR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				trait = papal_icon				
			}
			OR = { 
				religion = catholic
				religion = fraticelli
			}
			higher_real_tier_than = DUKE
		}
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20384
		hidden_tooltip = { FROM = { character_event = { id = HF.20385 } } }
		opinion = {
			modifier = opinion_uncrowned_ruler
			years = 5
			who = FROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Ruler: Chancellor reminded you that you are still uncrowned.
character_event = {
	id = HF.20385
	desc = EVTDESCHFA20385

	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20385
		add_character_modifier = {
			name = chancellor_of_uncrowned
			duration = 3650
			stacking = yes
		}
		tooltip = {
			FROM = {
				show_scope_change = no	
				opinion = {
					modifier = opinion_uncrowned_ruler
					years = 5
					who = ROOT
				}
			}
		}
		opinion = {
			modifier = opinion_dislike
			years = 5
			who = FROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Court Chaplain: You resign out of protest because liege is uncrowned.
character_event = {
	id = HF.20386
	desc = EVTDESCHFA20386

	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	trigger = { 
		has_dlc = "Holy Fury"
		liege = {
			NOR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
				trait = papal_icon		
			}
			OR = { 
				religion = catholic
				religion = fraticelli
			}
			higher_real_tier_than = DUKE
		}
	}

	option = {
		name = EVTOPTAHF20386
		hidden_tooltip = { FROM = { character_event = { id = HF.20387 } } }
		remove_title = job_spiritual
		add_character_modifier = { 
			name = resigned_in_anger
			duration = -1
		}

		piety = 50
		opinion = {
			modifier = opinion_uncrowned_ruler
			years = 15
			who = FROM
		}
		ai_chance = { 	
			factor = 100
		}
	}
	option = {
		name = EVTOPTBHF20386
		ai_chance = { 	
			factor = 0
		}
	}
}

#Court Chaplain: You resign out of protest because liege is uncrowned.
character_event = {
	id = HF.20387
	desc = EVTDESCHFA20387

	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20387
		tooltip = { 
			FROM = { 
				remove_title = job_spiritual  
				add_character_modifier = { 
					name = resigned_in_anger
					duration = -1
				}
			}
		}
		hidden_tooltip = { 
			FROM = { 
			remove_opinion = { 
					who = ROOT
					modifier = opinion_fired_from_council  
				}
			}
		} 
		ai_chance = { 	
			factor = 100
		}
	}
}

#Emperor crowned in barn humbled.
character_event = {
	id = HF.20388
	desc = EVTDESCHFA20388

	picture = GFX_evt_knight_kneeling
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	trigger = { 
		tier = EMPEROR
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself	
		}
		has_character_modifier = crowned_in_barn
	 } 

	option = {
		name = EVTOPTAHF20388
		trigger = { NOT = { trait = humble } } 
		prestige = -100
		if = { 
			limit = { trait = proud }
			remove_trait = proud
		} 
		add_trait = humble
		ai_chance = { 	
			factor = 40
		}
	}
	option = {
		name = EVTOPTBHF20388
		trigger = { trait = humble } 
		tooltip_info = humble
		prestige = -150
		piety = 50
		ai_chance = { 	
			factor = 40
		}
	}
	option = {
		name = EVTOPTCHF20388
		piety = -50
		if = { 
			limit = { trait = humble }
			remove_trait = humble
		} 
		ai_chance = { 	
			factor = 20
		}
	}
}

#Peasants are still celebrating coronation.
character_event = {
	id = HF.20389
	desc = EVTDESCHFA20389

	picture = GFX_evt_market_hf
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes

	trigger = { 
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
		has_character_modifier = extravagant_coronation
	 } 

	option = { #Use excitement to build trade
		name = EVTOPTAHF20389
		trigger = { stewardship = 12 } 
		tooltip_info = stewardship
		wealth = 50
		prestige = 100
		capital_scope = {
			add_province_modifier = {
				name = coronation_improved_trade
				duration = 1265
				stacking = yes
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
	option = { #Let peasants have their fun.
		name = EVTOPTBHF20389
		prestige = 100
		capital_scope = {
			add_province_modifier = {
				name = coronation_peasants_happy
				duration = 600
				stacking = yes
			}
		}
		ai_chance = { 	
			factor = 30
		}
	}
	option = { #Have peasants return to work.
		name = EVTOPTCHF20389
		prestige = -100
		capital_scope = {
			add_province_modifier = {
				name = peasants_scorned
				duration = 400
				stacking = yes
			}
		}
		ai_chance = { 	
			factor = 10
		}
	}
}

#Word of the great coronation has spread across the realm, bringing even more prestige to the new ruler.
character_event = {
	id = HF.20390
	desc = EVTDESCHFA20390

	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes

	trigger = { 
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
		has_character_modifier = extravagant_coronation
	 } 

	option = { 
		name = EVTOPTAHF20390
		prestige = 200
		ai_chance = { 	
			factor = 100
		}
	}
}

#Festivities for the coronation have brought in more trade.
character_event = {
	id = HF.20391
	desc = EVTDESCHFA20391

	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_economy

	is_triggered_only = yes

	trigger = { 
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
		has_character_modifier = extravagant_coronation
	 } 

	option = { #Use excitement to build trade
		name = EVTOPTAHF20391
		wealth = 75
		capital_scope = {
			add_province_modifier = {
				name = coronation_improved_trade
				duration = 1265
				stacking = yes
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Former guest is envious of extravagant coronation.
character_event = {
	id = HF.20392
	desc = {
		trigger = {
			has_character_modifier = crowned_in_barn
		}
		text = EVTDESCHFA20392		
	}
	desc = {
		trigger = {
			NOT = { has_character_modifier = crowned_in_barn }
		}
		text = EVTDESCHFB20392		
	}

	picture = GFX_evt_bad_news
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = { 
		FROMFROM = { has_character_modifier = extravagant_coronation }
		OR = { 
			has_character_modifier = crowned_in_barn
			NOR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
	 } 
	option = { 
		name = EVTOPTAHF20392
		trigger = { trait = humble } 
		tooltip_info = humble
		piety = 50
		ai_chance = { 	
			factor = 50
		}
	}

	option = { 
		name = EVTOPTBHF20392
		if = { 
			limit = { trait = kind } 
			remove_trait = kind
			break = yes
		}
		if = { 
			limit = { 
				NOR = { 
					trait = kind 
					trait = envious
				} 
			} 
			add_trait = envious
			break = yes
		}
		if = { 
			limit = { trait = envious } 
			piety = -50
			break = yes
		}
		ai_chance = { 	
			factor = 50
		}
	}
}

###############################
#New Vassals must pay homage to a crowned King.

#On_death event for vassal of crowned ruler.
character_event = {
	id = HF.20393
	hide_window = yes

	is_triggered_only = yes

	only_rulers = yes

	trigger = {
		has_dlc = "Holy Fury"
		religion_group = christian
		is_feudal = yes 
		independent = no
		higher_real_tier_than = COUNT #Avoid spamming.
		current_heir = { age = 12 } #At the very least
		liege = { 
			NOT = { character = ROOT }
			NOT = { 
				current_heir = { character = PREV } 
			}
			NOT = { #Prevent same vassal from giving homage multiple times when inheriting new titles within the realm (from siblings and such)
				current_heir = { vassal_of = PREV } 
			}
			religion_group = christian
			higher_real_tier_than = DUKE
			OR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
			in_command = no
		}
	 } 

	immediate = { 
		current_heir = { character_event = { id = HF.20394 days = 4 random = 4 } }
	}
}

#Heir is prompted to go to his liege.
character_event = {
	id = HF.20394
	desc = EVTDESCHFA20394		

	picture = GFX_evt_diplomatic_greeting
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = { 
		independent = no
		age = 12
		is_feudal = yes 
		religion_group = christian
		liege = { 
			NOT = { character = ROOT }
			higher_real_tier_than = DUKE
			is_inaccessible_trigger = no
			OR = { 
				trait = crowned_by_priest
				trait = crowned_by_bishop
				trait = crowned_by_pope
				trait = crowned_by_myself
			}
		}
	}

	option = { #Will go.
		name = EVTOPTAHF20394
		prestige = -50
		add_character_modifier = {
			name = out_traveling
			duration = 50
		}
		hidden_tooltip = { liege = { character_event = { id = HF.20396 days = 25 random = 10 } } } #Liege event.

		ai_chance = { 	
			factor = 80
		}
	}
	option = { #Will not go.
		name = EVTOPTBHF20394
		hidden_tooltip = { liege = { character_event = { id = HF.20395 days = 15 random = 15 } } } #Notify.

		liege = {
				show_scope_change = no	
			opinion = {
				modifier = opinion_didnot_pay_homage
				years = 15
				who = ROOT
			}
		}
		ai_chance = { 	
			factor = 20
			modifier = {
				factor = 0
				liege = { is_friend = ROOT }
			}
			modifier = {
				factor = 0
				liege = { is_lover = ROOT }
			}
			modifier = {
				factor = 0.5
				liege = { is_married = ROOT }
			}
			modifier = {
				factor = 0.5
				liege = { is_close_relative = ROOT }
			}
			modifier = {
				factor = 4
				liege = { is_rival = ROOT }
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = stubborn
			}
			modifier = {
				factor = 1.5
				trait = shy
			}
			modifier = {
				factor = 1.5
				liege = { NOT = { religion = ROOT } }
			}
			modifier = {
				factor = 1.5
				NOT = { 
					opinion = { 
						who = FROM
						value = 0 
					} 
				}
			}
			modifier = {
				factor = 1.5
				NOT = { 
					opinion = { 
						who = FROM
						value = -20 
					} 
				}
			}
			modifier = {
				factor = 2
				NOT = { 
					opinion = { 
						who = FROM
						value = -40 
					} 
				}
			}
			modifier = {
				factor = 3
				NOT = { 
					opinion = { 
						who = FROM
						value = -60 
					} 
				}
			}
		}
	}
}

#Liege notified new vassal won't pay him homage.
character_event = {
	id = HF.20395
	desc = EVTDESCHFA20395	

	picture = GFX_evt_courier
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = { 
		higher_real_tier_than = DUKE
		is_inaccessible_trigger = no
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
		}
	}

	option = {
		name = EVTOPTAHF20395
		prestige = -50
		tooltip = {
			opinion = {
				modifier = opinion_didnot_pay_homage
				years = 15
				who = FROM
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

#Liege receives homage from vassal.
character_event = {
	id = HF.20396
	desc = EVTDESCHFA20396

	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	trigger = { 
		higher_real_tier_than = DUKE
		OR = { 
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			trait = papal_icon	
		}
	}

	option = { #Accept homage
		name = EVTOPTAHF20396
		custom_tooltip = { text = tooltip_HF20396_A }
		hidden_tooltip = { 
			random_list = { 
				20 = { 
					modifier = {
						factor = 0
						religion = FROM 
					}
					set_character_flag = flag_homage_infidel
				}
				20 = { 
					modifier = {
						factor = 0
						FROM = { age = 16 }
					}
					set_character_flag = flag_homage_child
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { FROM = { age = 50 } }
					}
					set_character_flag = flag_homage_old
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { FROM = { is_attractive_trigger = yes } }
					}
					modifier = {
						factor = 0
						FROM = { is_female = yes }
						prefers_men_trigger = yes
					}
					modifier = {
						factor = 0
						FROM = { is_female = no }
						prefers_men_trigger = no
					}
					set_character_flag = flag_homage_attractive
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { FROM = { is_unattractive_trigger = yes } } 
					}
					set_character_flag = flag_homage_deformed
				}
				20 = { 
					modifier = {
						factor = 0
						FROM = { is_female = no }
						OR = { 
							has_law = agnatic_succession
							has_law = cognatic_succession 
						}
					}
					modifier = {
						factor = 0
						FROM = { is_female = yes }
						OR = { 
							has_law = enatic_cognatic_succession
							has_law = enatic_succession 
						}
					}
					set_character_flag = flag_homage_sex
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { FROM = { is_evil_trigger = yes } }  
					}
					set_character_flag = flag_homage_evil
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { FROM = { has_virtue_trigger = yes } }  
					}
					set_character_flag = flag_homage_good
				}
				1 = {
					set_character_flag = flag_homage_generic
				}
			} 

			character_event = { id = HF.20410 } # Reaction event.
		}
		ai_chance = { 	
			factor = 95
		}
	}
	option = { #Refuse homage
		name = EVTOPTBHF20396
		hidden_tooltip = { FROM = { character_event = { id = HF.20398 } } } #Notify.
		prestige = 100
		FROM = {
				show_scope_change = no	
			opinion = {
				modifier = opinion_offended
				years = 15
				who = ROOT
			}
		} 
		ai_chance = { 	
			factor = 5
			modifier = {
				factor = 0
				liege = { is_friend = ROOT }
			}
			modifier = {
				factor = 0
				liege = { is_lover = ROOT }
			}
			modifier = {
				factor = 0.5
				liege = { is_married = ROOT }
			}
			modifier = {
				factor = 0.5
				liege = { is_close_relative = ROOT }
			}
			modifier = {
				factor = 6
				liege = { is_rival = ROOT }
			}
			modifier = {
				factor = 1.5
				trait = envious
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = stubborn
			}
			modifier = {
				factor = 1.5
				NOT = { 
					opinion = { 
						who = FROM
						value = 0 
					} 
				}
			}
			modifier = {
				factor = 1.75
				NOT = { 
					opinion = { 
						who = FROM
						value = -20 
					} 
				}
			}
			modifier = {
				factor = 2
				NOT = { 
					opinion = { 
						who = FROM
						value = -40 
					} 
				}
			}
			modifier = {
				factor = 3
				NOT = { 
					opinion = { 
						who = FROM
						value = -60 
					} 
				}
			}
		}
	}
}
#Vassal notified liege accepted homage. - OBSOLETE, now chain leads into HF.20410.
#character_event = {
#	id = HF.20397
#	desc = EVTDESCHFA20397
#
#	picture = GFX_evt_emissary
#	border = GFX_event_normal_frame_diplomacy
#
#	is_triggered_only = yes
#
#	option = {
#		name = EVTOPTAHF20397
#		prestige = 100
#		tooltip = {
#			opinion = {
#				modifier = opinion_kind
#				years = 15
#				who = FROM
#			}
#		}
#		ai_chance = { 	
#			factor = 100
#		}
#	}
#}

#Vassal notified liege did not accept homage.
character_event = {
	id = HF.20398
	desc = EVTDESCHFA20398

	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20398
		prestige = -75
		tooltip = {
			opinion = {
				modifier = opinion_offended
				years = 15
				who = FROM
			}
		}
		ai_chance = { 	
			factor = 100
		}
	}
}

################################################
#Crown-related flavor. Triggered on_action randomly.

#The nail in the Iron Cross.
character_event = {
	id = HF.20399
	desc = EVTDESCHFA20399

	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	ai = no
	min_age = 8

	trigger = { 	
		NOT = { has_dynasty_flag = flag_nail_in_crown }
		NOT = { is_inaccessible_trigger = yes }
		religion_group = christian
		any_artifact = {
			artifact_type = iron_crown_of_lombardy
			is_artifact_equipped = yes 
		}
	}

	is_triggered_only = yes

	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.5
			trait = shrewd
		}
		modifier = {
			factor = 0.5
			trait = dull
		}
		modifier = {
			factor = 1.25
			trait = scholar
		}
		modifier = {
			factor = 2
			trait = cynical
		}
		modifier = {
			factor = 2
			NOT = { age = 16 }
		}
	}

	immediate = { set_dynasty_flag = flag_nail_in_crown }


	option = { #Look for it
		name = EVTOPTAHF20399
		change_learning = 3
		random = {
			chance = 10
			piety = -100
			custom_tooltip = { text = iron_cross_broken }
			hidden_tooltip = { 
				any_artifact = { 
					limit = { artifact_type = iron_crown_of_lombardy }
					unsafe_destroy_artifact = yes
					add_artifact = fragment_of_true_cross
				}
			}
		}
	}
	option = { #Better not to touch.
		name = EVTOPTBHF20399
		piety = 75
	}
}

#The HRE crown and the prince. 
character_event = {
	id = HF.20400
	hide_window = yes

	ai = no

	is_triggered_only = yes

	trigger = { 	
		NOT = { has_dynasty_flag = flag_hre_crown_prince }
		NOT = { has_character_flag = is_charlemagne }
		NOT = { is_inaccessible_trigger = yes }
		religion_group = christian
		has_landed_title = e_hre
		any_artifact = {
			artifact_type = crown_hre
			is_artifact_equipped = yes 
		}
		any_child = {
			is_alive = yes
			age = 7
			NOT = { age = 14 }
			NOT = { trait = incapable }
			prisoner = no
			NOT = { is_inaccessible_trigger = yes }
			at_location = ROOT
		}
	}

	weight_multiplier = {
		days = 1
		modifier = {
			factor = 1.75
			any_child = {
				is_alive = yes
				age = 7
				NOT = { age = 14 }
				NOT = { trait = incapable }
				prisoner = no
				NOT = { is_inaccessible_trigger = yes }
				at_location = ROOT
				trait = curious
			}
		}
		modifier = {
			factor = 1.5
			any_child = {
				is_alive = yes
				age = 7
				NOT = { age = 14 }
				NOT = { trait = incapable }
				prisoner = no
				NOT = { is_inaccessible_trigger = yes }
				at_location = ROOT
				trait = rowdy
			}
		}
	}


	immediate = { 
		set_dynasty_flag = flag_hre_crown_prince
		random_child = {
			limit = { 
				is_alive = yes
				age = 7
				NOT = { age = 14 }
				NOT = { trait = incapable }
				prisoner = no
				NOT = { is_inaccessible_trigger = yes } 
				at_location = ROOT
			}
			character_event = { id = HF.20401 } 
		}
	}
}

#Child picks the crown.
character_event = {
	id = HF.20401
	desc = EVTDESCHFA20401

	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = { 
		name = EVTOPTAHF20401
		prestige = 100
		hidden_tooltip = { FROM = { character_event = { id = HF.20402 } } } 
	}
}

#Emperor notified.
character_event = {
	id = HF.20402
	desc = EVTDESCHFA20402

	picture = GFX_evt_holy_emperor
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = { #Teach about the crown's history.
		name = EVTOPTAHF20402
		hidden_tooltip = { FROM = { character_event = { id = HF.20403 } } } 
		trigger = { 
			OR = { 
				learning = 12 
				trait = scholar
			} 
		}
		tooltip_info = learning
		piety = 30
		FROM = { 
			prestige = -75 
			change_learning = 1
		}
	}
	option = { #Pick back crown.
		name = EVTOPTBHF20402
		hidden_tooltip = { FROM = { character_event = { id = HF.20404 } } } 
		piety = 50
		FROM = { 
			prestige = -100 
			opinion = {
				modifier = opinion_scolded
				years = 5
				who = ROOT
			}
		}
	}
	option = { #Let the child have his fun.
		name = EVTOPTCHF20402
		piety = -50
		FROM = { 
			tooltip = { prestige = 100 }
			opinion = {
				modifier = opinion_forgiving_parent
				years = 5
				who = ROOT
			}
		}
	}
}
#Child taught lesson.
character_event = {
	id = HF.20403
	desc = EVTDESCHFA20403

	picture = GFX_evt_child_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = { 
		name = EVTOPTAHF20403
		tooltip = { 
			prestige = -75
			change_learning = 1
		}
		
	}
}

#Child reprimanded.
character_event = {
	id = HF.20404
	desc = EVTDESCHFA20404

	picture = GFX_evt_child_bully
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = { 
		name = EVTOPTAHF20404
		tooltip = { 
			prestige = -100 
			opinion = {
				modifier = opinion_scolded
				years = 5
				who = FROM
			}
		}
	}
}

#Thicking negative modifier for uncrowned rulers. Fired Five-Yearly.
character_event = {
	id = HF.20405
	hide_window = yes


	only_rulers = yes
	min_age = 16

	is_triggered_only = yes

	trigger = { 
		has_dlc = "Holy Fury"
		is_feudal = yes
		is_adult = yes
		is_vice_royalty = no
		NOT = { government = order_government }
		higher_real_tier_than = DUKE
		OR = { 
			religion = catholic
			religion = fraticelli
		}
		NOT = { check_variable = { which = uncrowned_count value = 30 } } #Stop at minus thirty.
		NOR =  { 
			trait = papal_icon
			trait = crowned_by_priest
			trait = crowned_by_bishop
			trait = crowned_by_pope
			trait = crowned_by_myself
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
		}
	}

	immediate = { 
		change_variable = { which = uncrowned_count value = 1 }
		add_character_modifier = {
			name = uncrowned_modifier
			duration = -1
			stacking = yes
		}
	}
}

#On_death. Artifact inheritance for special crowns.
character_event = {
	id = HF.20406
	hide_window = yes


	only_rulers = yes

	is_triggered_only = yes

	trigger = { 
		has_dlc = "Holy Fury"
		OR =  { 
			AND =  { 
				has_landed_title = e_hre 
				any_artifact = { artifact_type = crown_hre }
				e_hre = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = e_byzantium 
				any_artifact = { artifact_type = crown_byzantine }
				e_byzantium = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_norse_pagan_reformed 
				any_artifact = { artifact_type = crown_fylkir }
				d_norse_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_tengri_pagan_reformed 
				any_artifact = { artifact_type = crown_tengri_fylkir }
				d_tengri_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_finnish_pagan_reformed 
				any_artifact = { artifact_type = crown_finnish_fylkir }
				d_finnish_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_west_african_pagan_reformed 
				any_artifact = { artifact_type = crown_west_african_fylkir }
				d_west_african_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_zun_pagan_reformed 
				any_artifact = { artifact_type = crown_zun_fylkir }
				d_zun_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = k_hellenic_pagan
				any_artifact = { artifact_type = scepter_hellenic_fylkir }
				k_hellenic_pagan = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_slavic_pagan_reformed 
				any_artifact = { artifact_type = crown_slavic_fylkir }
				d_slavic_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_baltic_pagan_reformed 
				any_artifact = { artifact_type = crown_romuva_fylkir }
				d_baltic_pagan_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_bon_reformed 
				any_artifact = { artifact_type = scepter_bon_fylkir }
				d_bon_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = d_aztec_reformed 
				any_artifact = { artifact_type = crown_aztec_fylkir }
				d_aztec_reformed = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
			AND =  { 
				has_landed_title = e_persia 
				any_artifact = { artifact_type = crown_pahlavi }
				e_persia = { 
					current_heir = { 
						NOT = { dynasty = ROOT }
					} 
				} 
			}
		}
	}

	immediate = { 
		if = { 
			limit = { 
				has_landed_title = e_hre
				any_artifact = { artifact_type = crown_hre }
			}
			e_hre = { 
				current_heir = { save_event_target_as = worthy_hre_crown }
			}
			player_heir = { save_event_target_as = unworthy_hre_crown }
			any_artifact = { 
				limit = { artifact_type = crown_hre }
				save_event_target_as = inheriting_artifact_1
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = e_byzantium
				any_artifact = { artifact_type = crown_byzantine }
			}
			e_byzantium = { 
				current_heir = { save_event_target_as = worthy_byz_crown }
			}
			player_heir = { save_event_target_as = unworthy_byz_crown }
			any_artifact = { 
				limit = { artifact_type = crown_byzantine }
				save_event_target_as = inheriting_artifact_2
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_norse_pagan_reformed
				any_artifact = { artifact_type = crown_fylkir }
			}
			d_norse_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_fylkir }
				save_event_target_as = inheriting_artifact_3
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_tengri_pagan_reformed
				any_artifact = { artifact_type = crown_tengri_fylkir }
			}
			d_tengri_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_tengri_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_tengri_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_tengri_fylkir }
				save_event_target_as = inheriting_artifact_tengricrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_finnish_pagan_reformed
				any_artifact = { artifact_type = crown_finnish_fylkir }
			}
			d_finnish_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_finnish_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_finnish_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_finnish_fylkir }
				save_event_target_as = inheriting_artifact_finnishcrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_west_african_pagan_reformed
				any_artifact = { artifact_type = crown_west_african_fylkir }
			}
			d_west_african_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_west_african_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_west_african_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_west_african_fylkir }
				save_event_target_as = inheriting_artifact_west_africancrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_slavic_pagan_reformed
				any_artifact = { artifact_type = crown_slavic_fylkir }
			}
			d_slavic_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_slavic_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_slavic_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_slavic_fylkir }
				save_event_target_as = inheriting_artifact_slaviccrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_baltic_pagan_reformed
				any_artifact = { artifact_type = crown_romuva_fylkir }
			}
			d_baltic_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_baltic_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_baltic_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_romuva_fylkir }
				save_event_target_as = inheriting_artifact_balticcrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_bon_reformed
				any_artifact = { artifact_type = scepter_bon_fylkir }
			}
			d_bon_reformed = { 
				current_heir = { save_event_target_as = worthy_bon_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_bon_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = scepter_bon_fylkir }
				save_event_target_as = inheriting_artifact_boncrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_zun_pagan_reformed
				any_artifact = { artifact_type = crown_zun_fylkir }
			}
			d_zun_pagan_reformed = { 
				current_heir = { save_event_target_as = worthy_zun_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_zun_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_zun_fylkir }
				save_event_target_as = inheriting_artifact_zuncrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = k_hellenic_pagan
				any_artifact = { artifact_type = scepter_hellenic_fylkir }
			}
			k_hellenic_pagan = { 
				current_heir = { save_event_target_as = worthy_hellenic_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_hellenic_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = scepter_hellenic_fylkir }
				save_event_target_as = inheriting_artifact_helleniccrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = d_aztec_reformed
				any_artifact = { artifact_type = crown_aztec_fylkir }
			}
			d_aztec_reformed = { 
				current_heir = { save_event_target_as = worthy_aztec_fylkir_crown }
			}
			player_heir = { save_event_target_as = unworthy_aztec_fylkir_crown }
			any_artifact = { 
				limit = { artifact_type = crown_aztec_fylkir }
				save_event_target_as = inheriting_artifact_azteccrown
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
		if = { 
			limit = { 
				has_landed_title = e_persia
				any_artifact = { artifact_type = crown_pahlavi }
			}
			e_persia = { 
				current_heir = { save_event_target_as = worthy_pahlavi_crown }
			}
			player_heir = { save_event_target_as = unworthy_pahlavi_crown }
			any_artifact = { 
				limit = { artifact_type = crown_pahlavi }
				save_event_target_as = inheriting_artifact_4
			}
			current_heir = { character_event = { id = HF.20407 days = 1 } }
		}
	}
}
#Ping to prevent crown duplication.
character_event = {
	id = HF.20407
	hide_window = yes

	is_triggered_only = yes

	immediate = { 
		event_target:inheriting_artifact_1 = {
			transfer_artifact = {
				from = event_target:unworthy_hre_crown
				to = event_target:worthy_hre_crown
 			} 
 		} 
		event_target:inheriting_artifact_2 = {
			transfer_artifact = {
				from = event_target:unworthy_byz_crown
				to = event_target:worthy_byz_crown
 			} 
 		}
		event_target:inheriting_artifact_3 = {
			transfer_artifact = {
				from = event_target:unworthy_fylkir_crown
				to = event_target:worthy_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_tengricrown = {
			transfer_artifact = {
				from = event_target:unworthy_tengri_fylkir_crown
				to = event_target:worthy_tengri_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_finnishcrown = {
			transfer_artifact = {
				from = event_target:unworthy_finnish_fylkir_crown
				to = event_target:worthy_finnish_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_west_africancrown = {
			transfer_artifact = {
				from = event_target:unworthy_west_african_fylkir_crown
				to = event_target:worthy_west_african_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_slaviccrown = {
			transfer_artifact = {
				from = event_target:unworthy_slavic_fylkir_crown
				to = event_target:worthy_slavic_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_balticcrown = {
			transfer_artifact = {
				from = event_target:unworthy_baltic_fylkir_crown
				to = event_target:worthy_baltic_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_boncrown = {
			transfer_artifact = {
				from = event_target:unworthy_bon_fylkir_crown
				to = event_target:worthy_bon_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_zuncrown = {
			transfer_artifact = {
				from = event_target:unworthy_zun_fylkir_crown
				to = event_target:worthy_zun_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_helleniccrown = {
			transfer_artifact = {
				from = event_target:unworthy_hellenic_fylkir_crown
				to = event_target:worthy_hellenic_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_azteccrown = {
			transfer_artifact = {
				from = event_target:unworthy_aztec_fylkir_crown
				to = event_target:worthy_aztec_fylkir_crown
 			} 
 		}
		event_target:inheriting_artifact_4 = {
			transfer_artifact = {
				from = event_target:unworthy_pahlavi_crown
				to = event_target:worthy_pahlavi_crown
 			} 
 		}
	}
}

#On_conversion. Ruler converted when in the middle of a coronation, cancel everything.
character_event = {
	id = HF.20408
	desc = {
		text = EVTDESCHFA20408
		trigger = { 
			NOR = { 
				religion = fraticelli
				religion = catholic
			}
		}
	}
	desc = {
		text = EVTDESCHFB20408
		trigger = { 
			OR = { 
				religion = fraticelli
				religion = catholic
			}
		}
	}

	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	only_rulers = yes
	min_age = 11

	is_triggered_only = yes

	trigger = { 
		OR = { 
			has_character_flag = flag_preparing_coronation
			has_character_flag = flag_crowned_by_priest
			has_character_flag = flag_crowned_by_bishop
			has_character_flag = flag_crowned_by_pope
			has_character_flag = flag_antipope_for_coronation 
			has_character_flag = flag_excommunicated_for_coronation  
			has_character_flag = flag_pepin_for_coronation  
		} 

		#Previous religion
		FROM = {
			OR = {
				religion = catholic
				religion = fraticelli
			}
		}
	} 

	immediate = { 
		clr_character_flag = flag_preparing_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope
		clr_character_flag = flag_antipope_for_coronation
		clr_character_flag = flag_excommunicated_for_coronation
		clr_character_flag = flag_pepin_for_coronation
	}
	option = { 
		name = {
			text = EVTOPTAHF20408
			trigger = {
				NOR = { 
					religion = catholic
					religion = fraticelli
				}
			}
		}
		name = {
			text = EVTOPTAHF20058
			trigger = {
				OR = { 
					religion = catholic
					religion = fraticelli
				}
			}
		}
		hidden_tooltip = { remove_trait = travelling }
		hidden_tooltip = { remove_character_modifier = out_traveling }
		hidden_tooltip = { set_variable = { which = coronation_count value = 0 } }
		clr_character_flag = flag_preparing_coronation #Still used when after waging wars
		clr_character_flag = flag_antipope_for_coronation 
		clr_character_flag = flag_excommunicated_for_coronation 
		clr_character_flag = flag_pepin_for_coronation 
		clr_character_flag = flag_extravagant_coronation
		clr_character_flag = flag_regular_coronation
		clr_character_flag = flag_secluded_coronation
		clr_character_flag = flag_crowned_by_priest
		clr_character_flag = flag_crowned_by_bishop
		clr_character_flag = flag_crowned_by_pope

		clr_character_flag = flag_coronation_foreign_friendship
		clr_character_flag = flag_coronation_vassal_friendship
		clr_character_flag = flag_coronation_diplomacy_boost
		clr_character_flag = flag_coronation_learning_boost
		clr_character_flag = flag_coronation_guest_opinions
		clr_character_flag = flag_coronation_gain_diligent 
		clr_character_flag = flag_coronation_gain_ambitious 
		clr_character_flag = flag_coronation_haughty_child 
		clr_character_flag = flag_coronation_priest_approves 
		clr_character_flag = flag_coronation_hre_talk 
		clr_character_flag = flag_coronation_pope_talk 
		clr_character_flag = flag_coronation_foreign_teacher 
		clr_character_flag = flag_coronation_priest_disapproves 
		clr_character_flag = flag_coronation_diplomatic_incident 
		clr_character_flag = flag_coronation_cynic_taunts 
		clr_character_flag = flag_coronation_wandering_knight 
		clr_character_flag = flag_coronation_wandering_priest
		clr_character_flag = flag_coronation_random_rivalry 
		clr_character_flag = flag_coronation_secluded_embarassed 
		clr_character_flag = flag_coronation_secluded_vassals 
		clr_character_flag = flag_coronation_secluded_priest 
		clr_character_flag = flag_coronation_secluded_ambitious 
		clr_character_flag = flag_coronation_secluded_proud 
		clr_character_flag = flag_coronation_secluded_steward 


		hidden_tooltip = { 
			any_playable_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
				}
				remove_trait = travelling
				remove_character_modifier = out_traveling
				character_event = { id = HF.20408 }
				remove_opinion = { 
					who = ROOT
					modifier = opinion_coronation_guest 
				}
			} 
			any_courtier_or_vassal = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
				}
				remove_trait = travelling
				remove_character_modifier = out_traveling
				character_event = { id = HF.20409 }
				remove_opinion = { 
					who = ROOT
					modifier = opinion_coronation_guest 
				}
			}
		}
	}
}
#Guest: King to be crowned converted. Coronation has been cancelled.
character_event = {
	id = HF.20409
	desc = EVTDESCHFA20409

	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20409
	}
}

#########################################################

#Liege receives homage from vassal - Expanded flavor.
character_event = {
	id = HF.20410
	desc = {
		text = EVTDESCHFA20410
		trigger = { 
			has_character_flag = flag_homage_infidel
		}
	}
	desc = {
		text = EVTDESCHFB20410
		trigger = { 
			has_character_flag = flag_homage_child
		}
	}
	desc = {
		text = EVTDESCHFC20410
		trigger = { 
			has_character_flag = flag_homage_old
		}
	}
	desc = {
		text = EVTDESCHFD20410
		trigger = { 
			has_character_flag = flag_homage_attractive
			FROMFROM = { is_female = no }
		}
	}
	desc = {
		text = EVTDESCHFDD20410
		trigger = { 
			has_character_flag = flag_homage_attractive
			FROMFROM = { is_female = yes }
		}
	}
	desc = {
		text = EVTDESCHFF20410
		trigger = { 
			has_character_flag = flag_homage_deformed
		}
	}
	desc = {
		text = EVTDESCHFG20410
		trigger = { 
			has_character_flag = flag_homage_sex
		}
	}
	desc = {
		text = EVTDESCHFH20410
		trigger = { 
			has_character_flag = flag_homage_evil
		}
	}
	desc = {
		text = EVTDESCHFI20410
		trigger = { 
			has_character_flag = flag_homage_good
		}
	}
	desc = {
		text = EVTDESCHFL20410
		trigger = { 
			has_character_flag = flag_homage_generic
		}
	}
	show_from_from = yes #Vassal

	picture = { 
		trigger = { 
			ROOT = { 
				is_female = no
			} 
		} 
		picture = GFX_evt_throne_room
	}
	picture = { 
		trigger = { 
			ROOT = { 
				is_female = yes
			} 
		} 
		picture = GFX_evt_homage_hf
	}
	border = GFX_event_normal_frame_diplomacy

	immediate = { 
		FROMFROM = { #Setup reaction for vassal.
			random_list = { 
				20 = { 
					modifier = {
						factor = 0
						religion = ROOT 
					}
					set_character_flag = flag_homage_infidel
				}
				20 = { 
					modifier = {
						factor = 0
						ROOT = { age = 16 }
					}
					set_character_flag = flag_homage_child
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { ROOT = { age = 50 } }
					}
					set_character_flag = flag_homage_old
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { ROOT = { is_attractive_trigger = yes } }
					}
					modifier = {
						factor = 0
						FROM = { is_female = yes }
						prefers_men_trigger = yes
					}
					modifier = {
						factor = 0
						FROM = { is_female = no }
						prefers_men_trigger = no
					}
					set_character_flag = flag_homage_attractive
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { ROOT = { is_unattractive_trigger = yes } } 
					}
					set_character_flag = flag_homage_deformed
				}
				20 = { 
					modifier = {
						factor = 0
						ROOT = { is_female = no }
						OR = { 
							has_law = agnatic_succession
							has_law = cognatic_succession 
						}
					}
					modifier = {
						factor = 0
						ROOT = { is_female = yes }
						OR = { 
							has_law = enatic_cognatic_succession
							has_law = enatic_succession 
						}
					}
					set_character_flag = flag_homage_sex
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { ROOT = { is_evil_trigger = yes } }  
					}
					set_character_flag = flag_homage_evil
				}
				20 = { 
					modifier = {
						factor = 0
						NOT = { ROOT = { has_virtue_trigger = yes } }  
					}
					set_character_flag = flag_homage_good
				}
				1 = {
					set_character_flag = flag_homage_generic
				}
			}
		}
	}

	is_triggered_only = yes

	option = { #Children play
		name = EVTOPTAHF20410
		custom_tooltip = { text = tooltip_HF20410_A }
		trigger = { 
			has_character_flag = flag_homage_child 
			NOT = { age = 16 }
		}
		hidden_tooltip = { 
			random_list = {
				75 = {
					modifier = {
						factor = 0.5
						FROMFROM = { trait = timid }
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = shy }
					}
					modifier = {
						factor = 1.5
						FROMFROM = { trait = playful }
					}
					modifier = {
						factor = 1.5
						FROMFROM = { trait = idolizer }
					}
					FROMFROM = { set_character_flag = flag_homage_play_success } 
				}
				25 = { 
					FROMFROM = { set_character_flag = flag_homage_play_failure } 
				}
			}
		} 
		ai_chance = { 	
			factor = 100
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 0.5
				trait = timid
			}
		}
	}
	option = { #Attracted
		name = EVTOPTBHF20410
		custom_tooltip = { text = tooltip_HF20410_B }
		trigger = { 
			has_character_flag = flag_homage_attractive 
			age = 16
			OR = { 
				AND = { 
					FROMFROM = { is_female = yes } 
					prefers_men_trigger = no
				}
				AND = { 
					FROMFROM = { is_female = no } 
					prefers_men_trigger = yes
				}
			}
		}
		hidden_tooltip = { 
			random_list = {
				50 = {
					modifier = {
						factor = 0
						FROMFROM = { prefers_men_trigger = yes }
						is_female = yes
					}
					modifier = {
						factor = 0
						FROMFROM = { prefers_men_trigger = no }
						is_female = no
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = chaste }
					}
					modifier = {
						factor = 0.1
						FROMFROM = { trait = celibate }
					}
					modifier = {
						factor = 0.25
						is_unattractive_trigger = yes
					}
					modifier = {
						factor = 1.75
						is_attractive_trigger = yes
					}
					modifier = {
						factor = 1.5
						FROMFROM = { trait = lustful }
					}
					modifier = {
						factor = 1.5
						FROMFROM = { trait = hedonist }
					}
					FROMFROM = { set_character_flag = flag_homage_seduce_success } 
				}
				50 = { 
					FROMFROM = { set_character_flag = flag_homage_seduce_failure } 
				}
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = {
				factor = 0.5
				trait = chaste
			}
			modifier = {
				factor = 0
				trait = celibate
			}
			modifier = {
				factor = 1.5
				trait = lustful
			}
			modifier = {
				factor = 1.5
				trait = hedonist
			}
		}
	}
	option = { #Mock
		name = EVTOPTCHF20410
		custom_tooltip = { text = tooltip_HF20410_C }
		trigger = { 
			has_character_flag = flag_homage_deformed
		}
		hidden_tooltip = { 
			random_list = {
				30 = {
					modifier = {
						factor = 0.5
						FROMFROM = { trait = envious }
					}
					modifier = {
						factor = 0.1
						FROMFROM = { trait = proud }
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = ambitious }
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = wroth }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = humble }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = content }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = kind }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = patient }
					}
					FROMFROM = { set_character_flag = flag_homage_mock_success } 
				}
				70 = { 
					FROMFROM = { set_character_flag = flag_homage_mock_failure } 
				}
			}
		}
		ai_chance = { 	
			factor = 50
			modifier = {
				factor = 0.5
				trait = kind
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
			modifier = {
				factor = 1.5
				trait = cruel
			}
			modifier = {
				factor = 1.5
				trait = envious
			}
		}
	}
	option = { #Formal greeting
		name = EVTOPTDHF20410
		custom_tooltip = { text = tooltip_HF20410_D }
		hidden_tooltip = { 
			random_list = {
				65 = {
					modifier = {
						factor = 0.5
						FROMFROM = { trait = gregarious }
					}
					modifier = {
						factor = 0.1
						FROMFROM = { trait = socializer }
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = arbitrary }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = shy }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = content }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = trusting }
					}
					FROMFROM = { set_character_flag = flag_homage_formal_success } 
				}
				35 = { 
					FROMFROM = { set_character_flag = flag_homage_formal_failure } 
				}
			}
		}
		ai_chance = { 	
			factor = 30
			modifier = {
				factor = 0.5
				trait = gregarious
			}
			modifier = {
				factor = 0.5
				trait = socializer
			}
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 1.5
				trait = paranoid
			}
		}
	}
	option = { #Informal greeting
		name = EVTOPTEHF20410
		custom_tooltip = { text = tooltip_HF20410_E }
		hidden_tooltip = { 
			random_list = {
				65 = {
					modifier = {
						factor = 0.5
						FROMFROM = { trait = shy }
					}
					modifier = {
						factor = 0.1
						FROMFROM = { trait = humble }
					}
					modifier = {
						factor = 0.5
						FROMFROM = { trait = just }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = gregarious }
					}
					modifier = {
						factor = 1.5
						FROMFROM = { trait = proud }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = content }
					}
					modifier = {
						factor = 1.75
						FROMFROM = { trait = trusting }
					}
					FROMFROM = { set_character_flag = flag_homage_informal_success } 
				}
				35 = { 
					FROMFROM = { set_character_flag = flag_homage_informal_failure } 
				}
			}
		}
		ai_chance = { 	
			factor = 30
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
			modifier = {
				factor = 0.5
				trait = just
			}
			modifier = {
				factor = 1.5
				trait = trusting
			}
		}
	}
	after = { 
		clr_character_flag = flag_homage_infidel
		clr_character_flag = flag_homage_child
		clr_character_flag = flag_homage_old
		clr_character_flag = flag_homage_attractive
		clr_character_flag = flag_homage_deformed
		clr_character_flag = flag_homage_sex
		clr_character_flag = flag_homage_evil
		clr_character_flag = flag_homage_good
		clr_character_flag = flag_homage_generic
		hidden_tooltip = { FROMFROM = { character_event = { id = HF.20411 } } } 
	}
}

#Vassal receives homage from vassal - Expanded flavor.
character_event = {
	id = HF.20411
	desc = {
		text = EVTDESCHFA20411
		trigger = { 
			has_character_flag = flag_homage_infidel
		}
	}
	desc = {
		text = EVTDESCHFB20411
		trigger = { 
			has_character_flag = flag_homage_child
		}
	}
	desc = {
		text = EVTDESCHFC20411
		trigger = { 
			has_character_flag = flag_homage_old
		}
	}
	desc = {
		text = EVTDESCHFD20411
		trigger = { 
			has_character_flag = flag_homage_attractive
			is_female = no
		}
	}
	desc = {
		text = EVTDESCHFDD20411
		trigger = { 
			has_character_flag = flag_homage_attractive
			is_female = yes
		}
	}
	desc = {
		text = EVTDESCHFF20411
		trigger = { 
			has_character_flag = flag_homage_deformed
		}
	}
	desc = {
		text = EVTDESCHFG20411
		trigger = { 
			has_character_flag = flag_homage_sex
		}
	}
	desc = {
		text = EVTDESCHFH20411
		trigger = { 
			has_character_flag = flag_homage_evil
		}
	}
	desc = {
		text = EVTDESCHFI20411
		trigger = { 
			has_character_flag = flag_homage_good
		}
	}
	desc = {
		text = EVTDESCHFL20411
		trigger = { 
			has_character_flag = flag_homage_generic
		}
	}

	picture = { 
		trigger = { 
			ROOT = { 
				is_female = no
			} 
		} 
		picture = GFX_evt_emissary
	}
	picture = { 
		trigger = { 
			ROOT = { 
				is_female = yes
			} 
		} 
		picture = GFX_evt_homage_hf
	}
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = { #Pleased.
		name = {
			text = EVTOPTAHF20411_A
			trigger = { 
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success 
					has_character_flag = flag_homage_informal_success
				}
			}
		}
		name = {
			text = EVTOPTAHF20411_B
			trigger = { 
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}
		opinion = { 
			modifier = opinion_pleased
			who = FROM
			years = 5
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20412 } } } 
		ai_chance = { 
			factor = 50
			modifier = {
				factor = 0
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}
	} 
	option = { #Offended
		name = {
			text = EVTOPTBHF20411_A
			trigger = { 
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success 
					has_character_flag = flag_homage_informal_success
				}
			}
		}
		name = {
			text = EVTOPTBHF20411_B
			trigger = { 
				OR = {
					has_character_flag = flag_homage_play_failure
					has_character_flag = flag_homage_seduce_failure
					has_character_flag = flag_homage_mock_failure
					has_character_flag = flag_homage_formal_failure
					has_character_flag = flag_homage_informal_failure
				}
			}
		}
		opinion = { 
			modifier = opinion_irritated
			who = FROM
			years = 5
		}
		hidden_tooltip = { FROM = { character_event = { id = HF.20413 } } } 
		ai_chance = { 
			factor = 50
			modifier = {
				factor = 0
				OR = {
					has_character_flag = flag_homage_play_success
					has_character_flag = flag_homage_seduce_success
					has_character_flag = flag_homage_mock_success
					has_character_flag = flag_homage_formal_success 
					has_character_flag = flag_homage_informal_success
				}
			}
		}
	}
	after = { 
		clr_character_flag = flag_homage_infidel
		clr_character_flag = flag_homage_child
		clr_character_flag = flag_homage_old
		clr_character_flag = flag_homage_attractive
		clr_character_flag = flag_homage_deformed
		clr_character_flag = flag_homage_sex
		clr_character_flag = flag_homage_evil
		clr_character_flag = flag_homage_good
		clr_character_flag = flag_homage_generic
		clr_character_flag = flag_homage_play_success
		clr_character_flag = flag_homage_seduce_success
		clr_character_flag = flag_homage_mock_success
		clr_character_flag = flag_homage_formal_success
		clr_character_flag = flag_homage_informal_success
		clr_character_flag = flag_homage_play_failure
		clr_character_flag = flag_homage_seduce_failure
		clr_character_flag = flag_homage_mock_failure
		clr_character_flag = flag_homage_formal_failure
		clr_character_flag = flag_homage_informal_failure 
	}
}

#King notified: New vassal was pleased with your greeting.
character_event = {
	id = HF.20412
	desc = EVTDESCHFA20412

	picture = { 
		trigger = { 
			ROOT = { 
				is_female = no
			} 
		} 
		picture = GFX_evt_throne_room
	}
	picture = { 
		trigger = { 
			ROOT = { 
				is_female = yes
			} 
		} 
		picture = GFX_evt_homage_hf
	}
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20412
		tooltip = { 
			FROM = {
				show_scope_change = no 
				opinion = { 
					modifier = opinion_pleased
					who = ROOT
					years = 5
				}
			}
		}
	}
}
#King notified: New vassal was not pleased with your greeting.
character_event = {
	id = HF.20413
	desc = EVTDESCHFA20413

	picture = { 
		trigger = { 
			ROOT = { 
				is_female = no
			} 
		} 
		picture = GFX_evt_throne_room
	}
	picture = { 
		trigger = { 
			ROOT = { 
				is_female = yes
			} 
		} 
		picture = GFX_evt_homage_hf
	}
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTAHF20413
		tooltip = { 
			FROM = {
				show_scope_change = no 
				opinion = { 
					modifier = opinion_irritated
					who = ROOT
					years = 5
				}
			}
		}
	}
}

#On_title_usurped: move special crowns to new holder. FROMFROM = old holder, FROM = title, ROOT = new holder.
character_event = {
	id = HF.20414
	hide_window = yes

	trigger = {
		OR = {	
			AND = {
				FROM = { title = e_hre } 
				FROMFROM = { any_artifact = { artifact_type = crown_hre } } 
			} 
			AND = {
				FROM = { title = e_persia } 
				FROMFROM = { any_artifact = { artifact_type = crown_pahlavi } } 
			} 
			AND = {
				FROM = { title = e_byzantium } 
				FROMFROM = { any_artifact = { artifact_type = crown_byzantine } } 
			} 
			AND = {
				FROM = { title = d_norse_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_fylkir } } 
			} 
			AND = {
				FROM = { title = d_tengri_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_tengri_fylkir } } 
			} 
			AND = {
				FROM = { title = d_finnish_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_finnish_fylkir } } 
			} 
		}
	}

	is_triggered_only = yes

	immediate = {

		if = {
			limit = {
				FROM = { title = e_hre } 
				FROMFROM = { any_artifact = { artifact_type = crown_hre } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_hre }
					save_event_target_as = inheriting_artifact_1
				}
			}
		}
		if = {
			limit = {
				FROM = { title = e_persia } 
				FROMFROM = { any_artifact = { artifact_type = crown_pahlavi } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_pahlavi }
					save_event_target_as = inheriting_artifact_4
				}
			}
		}
		if = {
			limit = {
				FROM = { title = e_byzantium } 
				FROMFROM = { any_artifact = { artifact_type = crown_byzantine } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_byzantine }
					save_event_target_as = inheriting_artifact_2
				}
			}
		}
		if = {
			limit = {
				FROM = { title = d_norse_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_fylkir } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_fylkir }
					save_event_target_as = inheriting_artifact_3
				}
			}
		}
		if = {
			limit = {
				FROM = { title = d_tengri_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_tengri_fylkir } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_tengri_fylkir }
					save_event_target_as = inheriting_artifact_tengricrown 
				}
			}
		}
		if = {
			limit = {
				FROM = { title = d_finnish_pagan_reformed } 
				FROMFROM = { any_artifact = { artifact_type = crown_finnish_fylkir } } 
			} 
			FROMFROM = { 
				any_artifact = { 
					limit = { artifact_type = crown_finnish_fylkir }
					save_event_target_as = inheriting_artifact_finnishcrown
				}
			}
		}
		event_target:inheriting_artifact_1 = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		} 
		event_target:inheriting_artifact_2 = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		}
		event_target:inheriting_artifact_3 = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		}
		event_target:inheriting_artifact_tengricrown = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		}
		event_target:inheriting_artifact_finnishcrown = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		}
		event_target:inheriting_artifact_4 = {
			transfer_artifact = {
				from = FROMFROM
				to = ROOT
 			} 
 		} 
	}
}

#On_death: add special dead_crown trait to make the dead Emperors wear their special crowns even after they've given up the artifact itself.
character_event = {
	id = HF.20415
	hide_window = yes

	is_triggered_only = yes

	trigger = { 
		has_dlc = "Holy Fury"
		OR =  { 
			AND =  { 
				has_landed_title = e_hre 
				any_artifact = { artifact_type = crown_hre } 
			}
			AND =  { 
				has_landed_title = e_byzantium 
				any_artifact = { artifact_type = crown_byzantine }
			}
			AND =  { 
				has_landed_title = d_norse_pagan_reformed 
				any_artifact = { artifact_type = crown_fylkir }
			}
			AND =  { 
				has_landed_title = d_tengri_pagan_reformed 
				any_artifact = { artifact_type = crown_tengri_fylkir }
			}
			AND =  { 
				has_landed_title = d_finnish_pagan_reformed 
				any_artifact = { artifact_type = crown_finnish_fylkir }
			}
			AND =  { 
				has_landed_title = d_slavic_pagan_reformed 
				any_artifact = { artifact_type = crown_slavic_fylkir }
			}
			AND =  { 
				has_landed_title = d_baltic_pagan_reformed 
				any_artifact = { artifact_type = crown_romuva_fylkir }
			}
			AND =  { 
				has_landed_title = d_west_african_pagan_reformed 
				any_artifact = { artifact_type = crown_west_african_fylkir }
			}
			AND =  { 
				has_landed_title = k_hellenic_pagan
				any_artifact = { artifact_type = scepter_hellenic_fylkir }
			}
			AND =  { 
				has_landed_title = d_zun_pagan_reformed 
				any_artifact = { artifact_type = crown_zun_fylkir }
			}
			AND =  { 
				has_landed_title = d_aztec_reformed 
				any_artifact = { artifact_type = crown_aztec_fylkir }
			}
			AND =  { 
				has_landed_title = d_bon_reformed 
				any_artifact = { artifact_type = scepter_bon_fylkir }
			}
			AND =  { 
				has_landed_title = e_persia 
				any_artifact = { artifact_type = crown_pahlavi }
			}
			AND =  { 
				has_landed_title = k_italy 
				any_artifact = { artifact_type = iron_crown_of_lombardy }
			}
		#	AND =  { 
		#		any_artifact = { artifact_type = cursed_diamond_crown }
		#	}
		}
	}
	
	immediate = {
		if =  { 
			limit =  { 
				has_landed_title = e_hre 
				any_artifact = { artifact_type = crown_hre }
			}
			add_trait = dead_crown_hre
		}
		if =  { 
			limit =  { 
				has_landed_title = e_byzantium 
				any_artifact = { artifact_type = crown_byzantine }
			}
			add_trait = dead_crown_byzantine
		}
		if =  { 
			limit =  { 
				has_landed_title = d_norse_pagan_reformed 
				any_artifact = { artifact_type = crown_fylkir }
			}
			add_trait = dead_crown_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_tengri_pagan_reformed 
				any_artifact = { artifact_type = crown_tengri_fylkir }
			}
			add_trait = dead_crown_tengri_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_finnish_pagan_reformed 
				any_artifact = { artifact_type = crown_finnish_fylkir }
			}
			add_trait = dead_crown_finnish_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_slavic_pagan_reformed 
				any_artifact = { artifact_type = crown_slavic_fylkir }
			}
			add_trait = dead_crown_slavic_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_baltic_pagan_reformed 
				any_artifact = { artifact_type = crown_romuva_fylkir }
			}
			add_trait = dead_crown_romuva_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_west_african_pagan_reformed 
				any_artifact = { artifact_type = crown_west_african_fylkir }
			}
			add_trait = dead_crown_west_african_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_bon_reformed 
				any_artifact = { artifact_type = scepter_bon_fylkir }
			}
			add_trait = dead_scepter_bon_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_zun_pagan_reformed 
				any_artifact = { artifact_type = crown_zun_fylkir }
			}
			add_trait = dead_crown_zun_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = k_hellenic_pagan
				any_artifact = { artifact_type = scepter_hellenic_fylkir }
			}
			add_trait = dead_scepter_hellenic_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = d_aztec_reformed 
				any_artifact = { artifact_type = crown_aztec_fylkir }
			}
			add_trait = dead_crown_aztec_fylkir
		}
		if =  { 
			limit =  { 
				has_landed_title = e_persia 
				any_artifact = { artifact_type = crown_pahlavi }
			}
			add_trait = dead_crown_pahlavi
		}
		if =  { 
			limit =  { 
				has_landed_title = k_italy 
				any_artifact = { artifact_type = iron_crown_of_lombardy }
			}
			add_trait = dead_iron_crown_lombardy
		}
	}
}
#On_conversion: clean up uncrowned modifier.
character_event = {
	id = HF.20416
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_character_modifier = uncrowned_modifier
		NOR = {
			religion = catholic
			religion = fraticelli
		}
	}

	immediate = {
		remove_character_modifiers = { modifier = uncrowned_modifier amount = 30 } 	
		set_variable = { which = uncrowned_count value = 0 }
	}
}
#On_new_holder: clean up uncrowned modifier. FROMFROM = Title's old holder.
character_event = {
	id = HF.20417
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		FROMFROM = {
			has_character_modifier = uncrowned_modifier
			NOT = { #If no longer King-tier.
				higher_real_tier_than = DUKE
			}
		}
	}

	immediate = {
		FROMFROM = { 
			remove_character_modifiers = { modifier = uncrowned_modifier amount = 30 } 
			set_variable = { which = uncrowned_count value = 0 }
		} 	
	}
}

#Check edge cases of a ruler's heir inheriting a _for_coronation flag when the war itself is about to be invalidated for whatever reason.
character_event = {
	id = HF.20418
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_antipope_for_coronation 

	trigger = {
		NOT = {
			any_war = {
				using_cb = depose_antipope
			}
		}
	}

	immediate = {
		clr_character_flag = flag_antipope_for_coronation 
	}
}

character_event = {
	id = HF.20419
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_excommunicated_for_coronation  

	trigger = {
		OR = {
			lower_real_tier_than = KING
			NOT = {
				any_war = {
					using_cb = excommunicated_ruler
				}
			}
		}
	}

	immediate = {
		clr_character_flag = flag_excommunicated_for_coronation 
	}
}

character_event = {
	id = HF.20420
	hide_window = yes
	is_triggered_only = yes

	has_character_flag = flag_pepin_for_coronation   

	trigger = {
		OR = {
			lower_real_tier_than = KING
			NOT = {
				any_war = {
					using_cb = pepin_religious
				}
			}
		}
	}

	immediate = {
		clr_character_flag = flag_pepin_for_coronation
	}
}
